Exemplo n.º 1
0
        /// <summary>
        /// 新增巡店工作日志(门店拜访记录)
        /// </summary>
        /// <param name="User"></param>
        /// <param name="VisitWorkJson"></param>
        /// <returns>大于0:成功 -1:Json字符串无法解析 -2:新增拜访工作记录失败</returns>
        public static int VisitWorkAdd(UserInfo User, VisitWork Work)
        {
            LogWriter.WriteLog("PBMIFService.VisitWorkAdd:UserName="******",VisitWorkJson=" + JsonConvert.SerializeObject(Work));

            try
            {
                VisitWork v = Work;
                if (v == null) return -1;           //Json字符串无法解析

                VST_WorkListBLL bll;
                if (Work.ID == 0 || new VST_WorkListBLL(Work.ID).Model == null)
                {
                    bll = new VST_WorkListBLL();
                    bll.Model.RelateStaff = v.RelateStaff == 0 ? User.StaffID : v.RelateStaff;
                    bll.Model.Route = v.Route;
                    bll.Model.Client = v.Client;
                    bll.Model.Template = v.VisitTemplate;
                    bll.Model.WorkingClassify = v.WorkingClassify == 0 ? 1 : v.WorkingClassify;
                    bll.Model.IsComplete = v.IsComplete ? "Y" : "N";
                    bll.Model.BeginTime = v.BeginTime;
                    bll.Model.EndTime = v.EndTime;
                    bll.Model.PlanID = v.PlanID;
                    bll.Model.Remark = v.Remark;
                    bll.Model.ApproveFlag = 2;
                    bll.Model.InsertStaff = User.StaffID;
                }
                else
                {
                    bll = new VST_WorkListBLL(Work.ID);
                    bll.Model.IsComplete = v.IsComplete ? "Y" : "N";
                    bll.Model.EndTime = v.EndTime;
                    bll.Model.Remark = v.Remark;
                }

                if (bll.Model.ID == 0)
                {
                    int worklistid = bll.Add();
                    if (worklistid <= 0) return -2;     //新增拜访工作记录失败

                    Work.ID = worklistid;
                }
                else
                {
                    if (bll.Update() < 0) return -3;    //更新拜访工作记录失败
                }

                foreach (VisitWork.VisitWorkItem item in v.Items)
                {
                    if (item.WorkItemID > 0) continue;
                    VST_WorkItem detail = new VST_WorkItem();

                    detail.WorkList = Work.ID;
                    if (item.ProcessCode != "")
                    {
                        VST_Process m = new VST_ProcessBLL(item.ProcessCode).Model;
                        if (m != null) detail.Process = m.ID;
                    }
                    detail.WorkTime = item.WorkTime;
                    detail.Remark = item.Remark;

                    int detailid = bll.AddDetail(detail);

                    switch (item.ProcessCode)
                    {
                        #region 进店详细属性
                        case "JD":
                            {
                                int JobType = 0, JudgeMode = 0;
                                float Longitude = 0, Latitude = 0;

                                if (item.ExtParams.ContainsKey("JobType")) int.TryParse(item.ExtParams["JobType"].ToString(), out JobType);
                                if (item.ExtParams.ContainsKey("JudgeMode")) int.TryParse(item.ExtParams["JudgeMode"].ToString(), out JudgeMode);
                                if (item.ExtParams.ContainsKey("Longitude")) float.TryParse(item.ExtParams["Longitude"].ToString(), out Longitude);
                                if (item.ExtParams.ContainsKey("Latitude")) float.TryParse(item.ExtParams["Latitude"].ToString(), out Latitude);

                                VST_WorkItem_JDBLL jdbll = new VST_WorkItem_JDBLL();
                                jdbll.Model.Job = detailid;
                                jdbll.Model.JobType = JobType;
                                jdbll.Model.JudgeMode = JudgeMode;
                                jdbll.Model.Longitude = Longitude;
                                jdbll.Model.Latitude = Latitude;
                                if (item.ExtParams.ContainsKey("Remark")) jdbll.Model.Remark = item.ExtParams["Remark"].ToString();
                                jdbll.Add();
                                break;
                            }
                        #endregion
                        default:
                            break;
                    }
                }

                return Work.ID;
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("PBMIFService.VisitWorkAdd Exception Error!", err);
                return -100;
            }
        }
Exemplo n.º 2
0
            public VisitWorkItem(VST_WorkItem m)
            {
                WorkItemID = m.ID;

                if (m.Process != 0)
                {
                    Process = new VisitProcess(m.Process);
                    ProcessCode = Process.Code;
                }

                WorkTime = m.WorkTime;
                InsertTime = m.InsertTime;
                Remark = m.Remark;

                ExtParams = new Hashtable();

                switch (Process.Code)
                {
                    #region 进店详细属性
                    case "JD":
                        {
                            VST_WorkItem_JD jd = VST_WorkItem_JDBLL.GetDetailByJobID(m.ID);

                            //进出店类型
                            ExtParams.Add("JobType", jd.JobType);   //1:进店 2:离店

                            //进出店方式
                            ExtParams.Add("JudgeMode", jd.JudgeMode);   //1:查询 2:扫码 3:NFC

                            //经度
                            ExtParams.Add("Longitude", jd.Longitude);

                            //纬度
                            ExtParams.Add("Latitude", jd.Latitude);

                            try
                            {
                                //进出店类型字典名
                                if (jd.JobType > 0)
                                {
                                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_VisitJDType")[jd.JobType.ToString()];
                                    if (dic != null) ExtParams.Add("JobTypeName", dic.Name);
                                }

                                //进出店方式字典名
                                if (jd.JudgeMode > 0)
                                {
                                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("VST_VisitJudgeMode")[jd.JudgeMode.ToString()];
                                    if (dic != null) ExtParams.Add("JudgeModeName", dic.Name);
                                }
                            }
                            catch { }
                        }
                        break;
                    #endregion
                }
            }