Пример #1
0
        /// <summary>
        /// 同步商机专线信息到专线表
        /// 修改同步联系人数据
        /// </summary>
        /// <returns></returns>
        public IHttpActionResult ModifyDataSynchronization()
        {
            using (dbDataContext db = new dbDataContext())
            {
                //var plList = db.PrivateLine.Where(x => 1 == 1).Select(x => x.CompanyName);
                var bus = db.Business.Where(x => x.FUseWork == "专线");//商机专线信息
                if (bus.Count() > 0)
                {
                    foreach (var item in bus)//遍历商机的专线信息
                    {
                        var pl = db.PrivateLine.Where(x => x.CompanyName == item.CompanyName).FirstOrDefault();

                        if (pl != null)
                        {
                            if (item.Contacts.Count > 0)
                            {
                                foreach (var l in item.Contacts)
                                {
                                    var lxr = new PlContacts();
                                    lxr.Name = l.Name;
                                    lxr.Post = l.Post;
                                    lxr.Tel  = l.Tel;
                                    lxr.PlID = pl.ID;
                                    db.PlContacts.InsertOnSubmit(lxr);
                                }
                            }
                        }
                    }
                    db.SubmitChanges();
                }

                return(Json(new { }));
            }
        }
Пример #2
0
        /// <summary>
        /// 同步商机专线信息到专线表
        /// </summary>
        /// <returns></returns>
        public IHttpActionResult DataSynchronization()
        {
            using (dbDataContext db = new dbDataContext())
            {
                var plList = db.PrivateLine.Where(x => 1 == 1).Select(x => x.CompanyName);
                var bus    = db.Business.Where(x => x.FUseWork == "专线" && plList.Contains(x.CompanyName) == false);//商机专线信息
                if (bus.Count() > 0)
                {
                    foreach (var item in bus)//遍历商机的专线信息
                    {
                        var pl = new PrivateLine();
                        pl.CompanyAddress = item.CompanyAddress; //单位地址
                        pl.CompanyName    = item.CompanyName;    //单位名称
                        pl.CompanyScale   = item.FComputerNum;   //单位规模-------》电脑台数
                        pl.AddTime        = item.AddTime;
                        pl.LastTime       = item.LastTime;
                        pl.UserID         = item.UserID;
                        //for (int i = 0; i < Convert.ToInt32(item.FUseScale.Replace("条", "")); i++)//循环专线条数
                        //{
                        var plinfo = new PlInfo();
                        plinfo.BandWidth   = item.FUseBandWidth; //带宽
                        plinfo.Operator    = item.FOperator;     //运营商
                        plinfo.OverTime    = item.FOverTime;     //到期时间
                        plinfo.PayType     = "";                 //付费方式
                        plinfo.State       = 0;                  //状态
                        plinfo.WeekPrice   = item.FWeekPrice;    //周价
                        plinfo.PrivateLine = pl;                 //关联
                        db.PlInfo.InsertOnSubmit(plinfo);
                        //}
                        if (item.Contacts.Count > 0)
                        {
                            foreach (var l in item.Contacts)
                            {
                                var lxr = new PlContacts();
                                lxr.Name        = l.Name;
                                lxr.Post        = l.Post;
                                lxr.Tel         = l.Tel;
                                lxr.PrivateLine = pl;
                                db.PlContacts.InsertOnSubmit(lxr);
                            }
                        }



                        db.PrivateLine.InsertOnSubmit(pl);
                    }
                    db.SubmitChanges();
                }

                return(Json(new { }));
            }
        }
Пример #3
0
        public IHttpActionResult Modify([FromBody] RequestModel req)
        {
            try
            {
                //真实的参数
                var parameters = Common.AesDecryp.GetAesDecryp(req.data, req.secret);

                using (dbDataContext db = new dbDataContext())
                {
                    var UserID = Convert.ToInt32(parameters["UserID"]);                  //用户ID
                    var user   = db.Users.FirstOrDefault(x => x.ID == UserID);           //用户

                    var PlID = Convert.ToInt32(parameters["PlID"]);                      //专线ID
                    var pl   = db.PrivateLine.Where(x => x.ID == PlID).FirstOrDefault(); //专线
                    if (pl != null)
                    {
                        pl.CompanyAddress = parameters["CompanyAddress"];
                        pl.CompanyName    = parameters["CompanyName"];
                        pl.CompanyScale   = parameters["CompanyScale"];
                        pl.LastTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //最近更新时间
                        pl.Remark         = parameters["Remark"];                         //备注

                        #region 联系人
                        //联系人数量
                        var ContactsNum  = Convert.ToInt32(parameters["ContactsNum"]);
                        var Contacts     = new List <PlContacts>();    //联系人列表
                        var ContactsName = parameters["ContactsName"]; //联系人姓名(逗号隔开的多个)
                        var ContactsTel  = parameters["ContactsTel"];  //联系人电话(逗号隔开的多个)
                        var ContactsPost = parameters["ContactsPost"]; //联系人岗位(逗号隔开的多个)
                        //分割后
                        var ContactsNameList = ContactsName.Split(',');
                        var ContactsTelList  = ContactsTel.Split(',');
                        var ContactsPostList = ContactsPost.Split(',');
                        //遍历
                        for (int i = 0; i < ContactsNum; i++)
                        {
                            var contact = new PlContacts();
                            contact.Name        = ContactsNameList[i];
                            contact.Tel         = ContactsTelList[i];
                            contact.Post        = ContactsPostList[i];
                            contact.PrivateLine = pl;
                            Contacts.Add(contact);
                        }
                        #endregion
                        #region 专线信息
                        var PlInfoNum  = Convert.ToInt32(parameters["PlInfoNum"]);                                         //专线信息数量
                        var PlInfoList = new List <PlInfo>();                                                              //专线信息列表(新增)
                        //分割前
                        var PlInfoID        = parameters["PlInfoID"];                                                      //专线信息ID
                        var Type            = parameters["Type"];                                                          //类型
                        var Operator        = parameters["Operator"];                                                      //运营商
                        var WeekPrice       = parameters["WeekPrice"];                                                     //周价
                        var BandWidth       = parameters["BandWidth"];                                                     //带宽
                        var PayType         = parameters["PayType"];                                                       //付费方式
                        var OverTime        = parameters["OverTime"];                                                      //到期时间
                        var ServerBerSys    = parameters["ServerBerSys"];                                                  //是否有上云计划
                        var ServerUsingTime = parameters["ServerUsingTime"];                                               //现服务器开始使用时间
                        var IsCloudPlan     = parameters["IsCloudPlan"];                                                   //是否有上云计划
                        //分割后
                        var PlInfoIDList        = PlInfoID.Split(',');                                                     //专线信息ID
                        var TypeList            = Type.Split(',');                                                         //类型
                        var OperatorList        = Operator.Split(',');                                                     //运营商
                        var WeekPriceList       = WeekPrice.Split(',');                                                    //周价
                        var BandWidthList       = BandWidth.Split(',');                                                    //带宽
                        var PayTypeList         = PayType.Split(',');                                                      // 付费方式
                        var OverTimeList        = OverTime.Split(',');                                                     //到期时间
                        var ServerBerSysList    = ServerBerSys.Split(',');                                                 //服务器承载系统
                        var ServerUsingTimeList = ServerUsingTime.Split(',');                                              //现服务器开始使用时间
                        var IsCloudPlanList     = IsCloudPlan.Split(',');                                                  //是否有上云计划
                        //原有的专线信息ID
                        var oldPlInfoIDList = db.PlInfo.Where(x => x.PlID == pl.ID).Select(x => x.ID.ToString()).ToList(); //
                        for (int i = 0; i < PlInfoNum; i++)                                                                //遍历最新数据
                        {
                            if (PlInfoIDList[i] == "0")                                                                    //新增的
                            {
                                var plinfo = new PlInfo();
                                plinfo.Type            = Convert.ToInt32(TypeList[i]);//类型
                                plinfo.Operator        = OperatorList[i];
                                plinfo.WeekPrice       = WeekPriceList[i];
                                plinfo.BandWidth       = BandWidthList[i];
                                plinfo.PayType         = PayTypeList[i];
                                plinfo.OverTime        = !string.IsNullOrEmpty(OverTimeList[i]) ? Convert.ToDateTime(OverTimeList[i]).ToString("yyyy-MM-dd") : "";
                                plinfo.ServerBerSys    = ServerBerSysList[i];                                                //服务器承载系统
                                plinfo.ServerUsingTime = ServerUsingTimeList[i];
                                plinfo.IsCloudPlan     = IsCloudPlanList[i] != "" ? Convert.ToInt32(IsCloudPlanList[i]) : 0; //是否有上云计划
                                plinfo.State           = 0;
                                plinfo.PrivateLine     = pl;
                                PlInfoList.Add(plinfo);
                            }
                            else//修改的
                            {
                                //专线信息
                                var plinfo = db.PlInfo.Where(x => x.ID == Convert.ToInt32(PlInfoIDList[i])).FirstOrDefault();
                                plinfo.Type            = Convert.ToInt32(TypeList[i]);//类型
                                plinfo.Operator        = OperatorList[i];
                                plinfo.WeekPrice       = WeekPriceList[i];
                                plinfo.BandWidth       = BandWidthList[i];
                                plinfo.PayType         = PayTypeList[i];
                                plinfo.OverTime        = !string.IsNullOrEmpty(OverTimeList[i]) ? Convert.ToDateTime(OverTimeList[i]).ToString("yyyy-MM-dd") : "";
                                plinfo.ServerBerSys    = ServerBerSysList[i];                                            //服务器承载系统
                                plinfo.ServerUsingTime = ServerUsingTimeList[i];
                                plinfo.IsCloudPlan     = IsCloudPlanList[i] != ""?Convert.ToInt32(IsCloudPlanList[i]):0; //是否有上云计划
                                #region 状态判断
                                if (plinfo.State == 0)                                                                   //正常
                                {
                                    //正常修改不处理
                                }
                                else if (plinfo.State == 1)//已提醒
                                {
                                    var plremind = db.PlRemind.Where(x => x.PlID == PlID && x.PlInfoID == Convert.ToInt32(PlInfoIDList[i])).Where(x => x.Type == 1).OrderByDescending(x => x.AddTime).FirstOrDefault();
                                    if (plremind != null)
                                    {
                                        plremind.State = 2;//未处理
                                    }
                                }
                                else if (plinfo.State == 2)//已回执
                                {
                                    plinfo.State = 0;
                                }
                                #endregion
                                #region  除的
                                ////最新的数据中不包含原有的数据,则删除原有的数据
                                //新旧差集
                                var strID = oldPlInfoIDList.Except(PlInfoIDList);
                                if (strID.Count() > 0)
                                {
                                    foreach (var item in strID)//删除
                                    {
                                        var oldPlInfo = db.PlInfo.Where(x => x.ID == Convert.ToInt32(item)).FirstOrDefault();
                                        if (oldPlInfo != null)
                                        {
                                            var plremind = db.PlRemind.Where(x => x.PlInfoID == oldPlInfo.ID);

                                            db.PlInfo.DeleteOnSubmit(oldPlInfo);     //删除旧的专线数据
                                            db.PlRemind.DeleteAllOnSubmit(plremind); //删除原有的的提醒记录
                                        }
                                    }
                                }
                                #endregion
                            }
                        }

                        #endregion
                        db.PlContacts.DeleteAllOnSubmit(db.PlContacts.Where(x => x.PlID == pl.ID)); //删除旧的联系人
                        db.PlContacts.InsertAllOnSubmit(Contacts);                                  //添加最新的联系人
                        if (PlInfoList.Count > 0)
                        {
                            db.PlInfo.InsertAllOnSubmit(PlInfoList);//添加新的
                        }

                        db.SubmitChanges();

                        return(Json(new { state = 1, msg = "修改成功" }));
                    }
                    return(Json(new { state = 0, msg = "专线信息不存在" }));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public IHttpActionResult Add([FromBody] RequestModel req)
        {
            try
            {
                //真实的参数
                var parameters = Common.AesDecryp.GetAesDecryp(req.data, req.secret);

                using (dbDataContext db = new dbDataContext())
                {
                    var UserID = Convert.ToInt32(parameters["UserID"]);        //用户ID
                    var user   = db.Users.FirstOrDefault(x => x.ID == UserID); //用户
                    if (user != null)
                    {
                        PrivateLine pl = new PrivateLine();
                        pl.AddTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//添加时间
                        pl.CompanyAddress = parameters["CompanyAddress"];
                        pl.CompanyName    = parameters["CompanyName"];
                        pl.CompanyScale   = parameters["CompanyScale"];
                        pl.LastTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //最近更新时间
                        pl.Remark         = parameters["Remark"];                         //备注
                        pl.Users          = user;
                        pl.State          = Convert.ToInt32(parameters["State"]);
                        #region 联系人
                        //联系人数量
                        var ContactsNum  = Convert.ToInt32(parameters["ContactsNum"]);
                        var Contacts     = new List <PlContacts>();    //联系人列表
                        var ContactsName = parameters["ContactsName"]; //联系人姓名(逗号隔开的多个)
                        var ContactsTel  = parameters["ContactsTel"];  //联系人电话(逗号隔开的多个)
                        var ContactsPost = parameters["ContactsPost"]; //联系人岗位(逗号隔开的多个)
                        //分割后
                        var ContactsNameList = ContactsName.Split(',');
                        var ContactsTelList  = ContactsTel.Split(',');
                        var ContactsPostList = ContactsPost.Split(',');
                        //遍历
                        for (int i = 0; i < ContactsNum; i++)
                        {
                            var contact = new PlContacts();
                            contact.Name        = ContactsNameList[i];
                            contact.Tel         = ContactsTelList[i];
                            contact.Post        = ContactsPostList[i];
                            contact.PrivateLine = pl;
                            Contacts.Add(contact);
                        }
                        #endregion
                        #region 专线信息
                        var PlInfoNum  = Convert.ToInt32(parameters["PlInfoNum"]); //专线信息数量
                        var PlInfoList = new List <PlInfo>();                      //专线信息列表
                        //分割前
                        var Type            = parameters["Type"];                  //类型 1专线  2电路 3,天翼云
                        var Operator        = parameters["Operator"];              //运营商
                        var WeekPrice       = parameters["WeekPrice"];             //周价
                        var BandWidth       = parameters["BandWidth"];             //带宽
                        var PayType         = parameters["PayType"];               //付费方式
                        var OverTime        = parameters["OverTime"];              //到期时间
                        var ServerBerSys    = parameters["ServerBerSys"];          //服务器承载系统
                        var ServerUsingTime = parameters["ServerUsingTime"];       //现服务器开始使用时间
                        var IsCloudPlan     = parameters["IsCloudPlan"];           //是否有上云计划
                        //分割后
                        var TypeList            = Type.Split(',');                 //类型
                        var OperatorList        = Operator.Split(',');             //运营商
                        var WeekPriceList       = WeekPrice.Split(',');            //周价
                        var BandWidthList       = BandWidth.Split(',');            //带宽
                        var PayTypeList         = PayType.Split(',');              // 付费方式
                        var OverTimeList        = OverTime.Split(',');             //到期时间
                        var ServerBerSysList    = ServerBerSys.Split(',');         //服务器承载系统
                        var ServerUsingTimeList = ServerUsingTime.Split(',');      //现服务器开始使用时间
                        var IsCloudPlanList     = IsCloudPlan.Split(',');          //是否有上云计划
                        for (int i = 0; i < PlInfoNum; i++)
                        {
                            var plinfo = new PlInfo();
                            plinfo.Type            = Convert.ToInt32(TypeList[i]);//类型
                            plinfo.Operator        = OperatorList[i];
                            plinfo.WeekPrice       = WeekPriceList[i];
                            plinfo.BandWidth       = BandWidthList[i];
                            plinfo.PayType         = PayTypeList[i];
                            plinfo.OverTime        = !string.IsNullOrEmpty(OverTimeList[i]) ? Convert.ToDateTime(OverTimeList[i]).ToString("yyyy-MM-dd") : "";
                            plinfo.ServerBerSys    = ServerBerSysList[i];                                          //服务器承载系统
                            plinfo.ServerUsingTime = ServerUsingTimeList[i];
                            plinfo.IsCloudPlan     = IsCloudPlanList[i] != "" ? int.Parse(IsCloudPlanList[i]) : 0; //是否有上云计划
                            plinfo.State           = 0;
                            plinfo.PrivateLine     = pl;
                            PlInfoList.Add(plinfo);
                        }
                        #endregion
                        #region 走访记录
                        var plvisit = new PlVisit();
                        plvisit.AddTime       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//添加时间
                        plvisit.IsAgain       = Convert.ToInt32(parameters["IsAgain"]);
                        plvisit.IsNeed        = Convert.ToInt32(parameters["IsNeed"]);
                        plvisit.State         = 0;
                        plvisit.VisitTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //本次拜访时间
                        plvisit.NextTime      = parameters["NextTime"];
                        plvisit.IsOther       = Convert.ToInt32(parameters["IsOther"]);       //是否有其他业务
                        plvisit.OtherDesc     = parameters["OtherDesc"];                      //其他业务描述
                        plvisit.VisitContents = parameters["VisitContents"];                  //
                        plvisit.PrivateLine   = pl;
                        #endregion

                        db.PrivateLine.InsertOnSubmit(pl);
                        db.PlContacts.InsertAllOnSubmit(Contacts);
                        db.PlInfo.InsertAllOnSubmit(PlInfoList);
                        db.PlVisit.InsertOnSubmit(plvisit);
                        db.SubmitChanges();

                        return(Json(new { state = 1, msg = "添加成功" }));
                    }
                    return(Json(new { state = 0, msg = "用户不存在" }));
                }
            }
            catch (Exception ex)
            {
                //return Json(new { state = 0, msg = "请求失败" });
                throw ex;
            }
        }