using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;
using System.Text.RegularExpressions;

namespace HySoft.BaseCallCenter.Web.workordermanage.workorder
{
    public partial class shangchuanAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.Files["FileData"] != null)
                {
                    HttpPostedFile file = Request.Files["FileData"];
                    //string s = HttpContext.Current.Server.MapPath(Request["folder"]) + "\\";
                    string year = DateTime.Today.Year.ToString();
                    string month = DateTime.Today.Month.ToString();
                    string day = DateTime.Today.Day.ToString();
                    string path = @"\fujian\" + year + @"\" + month + @"\" + day + @"\";

                    string uploadpath = @"D:" + path;
                    string name = "(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")" + file.FileName;

                    if (file != null)
                    {
                        if (!Directory.Exists(uploadpath))
                        {
                            Directory.CreateDirectory(uploadpath);
                        }
                        file.SaveAs(uploadpath + name);
                        Response.Write("1");
                    }
                    else
                    {
                        Response.Write("0");
                    }
                    Model.T_Wo_WorkOrderFiles model_file = new Model.T_Wo_WorkOrderFiles();
                    BLL.T_Wo_WorkOrderFiles bll_file = new BLL.T_Wo_WorkOrderFiles();
                    Common.LoginUser user = new Common.LoginUser(this.Context);

                    model_file.F_NAME = file.FileName;
                    model_file.F_PATH = path + name;
                    model_file.F_WORKORDERID = 0;
                    model_file.F_DES = "";
                    model_file.F_TYPE = "4";
                    model_file.F_SIZE = file.ContentLength;
                    model_file.F_UPLOADSTATE = 1;
                    model_file.F_USERID = user.UserID;
                    
                    model_file.F_UPLOADDATE = DateTime.Now;
                    bll_file.Add(model_file);
                    string id = DBUtility.DbHelperSQL.MaxID("F_FILEID", "T_Wo_WorkOrderFiles").ToString();
                    if (Session["orderwenjian"] != null)
                    {
                        Session["orderwenjian"] = Session["orderwenjian"] + id + "xgxidname" + file.FileName + "xgxjw";
                    }
                }
            }
            catch { }
        }
    }
}