Ejemplo n.º 1
0
        public void Execute(IJobExecutionContext context)
        {
            // string path = System.Environment.CurrentDirectory; // MapPath("/App_Data/selfsetting.xml");
            HttpContext http   = HttpContext.Current;
            string      path   = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data/selfsetting.xml");
            XmlDocument xmldoc = new XmlDocument();

            //  string path =  System.AppDomain.CurrentDomain.BaseDirectory.ToString()+ "App_Data/selfsetting.xml";
            xmldoc.Load(path);
            string time         = xmldoc.SelectSingleNode("root").SelectSingleNode("daorutime").Attributes[0].Value;
            string daorupath    = xmldoc.SelectSingleNode("root").SelectSingleNode("daorudir").Attributes[0].Value;
            string daorunowdate = xmldoc.SelectSingleNode("root").SelectSingleNode("daorunowdate").Attributes[0].Value;

            var files = DirFileHelper.GetFileNames(daorupath);

            if (files.Length > 0)
            {
                DataSet        ds             = ExportFile.ExcelSqlConnection(files[0], "Info"); //调用自定义方法
                DataRow[]      dr             = ds.Tables[0].Select();
                int            successcount   = 0;
                int            failcount      = 0;
                M_HitchInfoBll M_HitchInfoBll = new M_HitchInfoBll();
                for (int i = 0; i < dr.Length; i++)
                {
                    try
                    {
                        M_HitchInfo model = new M_HitchInfo();
                        model.AreaName       = dr[0][0].ToString();
                        model.FactorySation  = dr[i][1].ToString();
                        model.Signal         = dr[i][2].ToString();
                        model.HappenTimes    = int.Parse(dr[i][3].ToString());
                        model.SignalType     = dr[i][4].ToString();
                        model.HappenTimes1   = int.Parse(dr[i][5].ToString());
                        model.MessageType    = dr[i][6].ToString();
                        model.CreateUserId   = 1;
                        model.CreateUserName = "******";
                        model.CreateTime     = DateTime.Now.AddDays(int.Parse(daorunowdate));
                        if (M_HitchInfoBll.M_HitchInfoAdd(model) > 0)
                        {
                            successcount++;
                        }
                        else
                        {
                            failcount++;
                        }
                    }
                    catch (Exception)
                    {
                        failcount++;
                    }
                }
                for (int i = 0; i < files.Length; i++)
                {
                    File.Delete(files[i]);
                }
            }
        }
        public Dictionary <string, object> IntoSalActivity()
        {
            T_SaleActivityBll bll      = new T_SaleActivityBll();
            string            url      = HttpContext.Current.Request.Form["url"].ToString();
            string            filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet           ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info"); //调用自定义方法

            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    T_SaleActivity model = new T_SaleActivity();
                    model.AgencyId            = int.Parse(dr[0][0].ToString());
                    model.AreaId              = int.Parse(dr[i][1].ToString());
                    model.ActivityDate        = DateTime.Parse(dr[i][2].ToString());
                    model.SaleActivityTypeId  = int.Parse(dr[i][3].ToString());
                    model.PassengerFlow       = int.Parse(dr[i][4].ToString());
                    model.LatentPassengerFlow = int.Parse(dr[i][5].ToString());
                    model.CarOwner            = int.Parse(dr[i][6].ToString());
                    model.OrderQuantity       = int.Parse(dr[i][7].ToString());
                    model.PrimeCost           = int.Parse(dr[i][8].ToString());
                    model.LaterOrderQuantity  = int.Parse(dr[i][9].ToString());
                    model.PublishWay          = dr[i][10].ToString();
                    model.CreateUserId        = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName      = ManageProvider.Provider.Current().Account;
                    model.CreateTime          = DateTime.Now;
                    model.IsDelete            = 0;
                    model.IsShow              = 1;
                    if (bll.Add(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }
Ejemplo n.º 3
0
        public Dictionary <string, object> IntoClubActivityInfo()
        {
            C_ClubActivityInfoBll bll = new C_ClubActivityInfoBll();
            string  url      = HttpContext.Current.Request.Form["url"].ToString();
            string  filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info");     //调用自定义方法

            log.Debug(ds.Tables[0].Rows.Count);
            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    C_ClubActivityInfo model = new C_ClubActivityInfo();

                    model.ClubName           = dr[i][0].ToString();
                    model.ClubActivityTypeId = int.Parse(dr[i][1].ToString());
                    model.ActivityDate       = DateTime.Parse(dr[i][2].ToString());
                    model.ActivityCost       = int.Parse(dr[i][3].ToString());
                    model.CreateUserId       = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName     = ManageProvider.Provider.Current().Account;
                    model.CreateTime         = DateTime.Now;
                    model.IsDelete           = 0;
                    model.IsShow             = 1;
                    if (bll.Add(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }
        //故障导入
        public Dictionary <string, object> LeadingInM_HitchInfo()
        {
            string  datetime = HttpContext.Current.Request.Form["leadingindatetime"].ToString();
            string  url      = HttpContext.Current.Request.Form["url"].ToString();
            string  filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info");     //调用自定义方法

            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    M_HitchInfo model = new M_HitchInfo();
                    model.AreaName       = dr[0][0].ToString();
                    model.FactorySation  = dr[i][1].ToString();
                    model.Signal         = dr[i][2].ToString();
                    model.HappenTimes    = int.Parse(dr[i][3].ToString());
                    model.SignalType     = dr[i][4].ToString();
                    model.HappenTimes1   = int.Parse(dr[i][5].ToString());
                    model.MessageType    = dr[i][6].ToString();
                    model.CreateUserId   = 1;
                    model.CreateUserName = "******";
                    model.CreateTime     = DateTime.Parse(datetime);
                    if (M_HitchInfoBll.M_HitchInfoAdd(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }
        public Dictionary <string, object> IntoAgency()
        {
            T_AgencyBll bll      = new T_AgencyBll();
            string      url      = HttpContext.Current.Request.Form["url"].ToString();
            string      filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet     ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info"); //调用自定义方法

            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    T_Agency model = new T_Agency();

                    model.AgencyName     = dr[i][0].ToString();
                    model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName = ManageProvider.Provider.Current().Account;
                    model.CreateTime     = DateTime.Now;
                    model.IsDelete       = 0;
                    model.IsShow         = 1;
                    model.SortCode       = 0;
                    if (bll.Add(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }