コード例 #1
0
        public void SavePartnerTask()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    if (string.IsNullOrEmpty(Request["TaskID"]))
                    {
                        throw new Exception("TaskID:参数无效");
                    }
                    if (string.IsNullOrEmpty(Request["UserCode"]))
                    {
                        throw new Exception("UserCode:参数无效");
                    }
                    if (string.IsNullOrEmpty(Request["StepName"]))
                    {
                        throw new Exception("StepName:参数无效");
                    }
                    if (string.IsNullOrEmpty(Request["ReferenceID"]))
                    {
                        throw new Exception("ReferenceID:参数无效");
                    }

                    //Database dbCheck = new Database("BE_Solution_Proc", "CHECKSL", 0, 0, Request["ReferenceID"].ToString(), "", "");
                    //string result= dbCheck.ExecuteScalar().ToString();
                    //if (result=="0")
                    //{
                    //    WriteError("请先提交拆单!");
                    //    return;
                    //}

                    PartnerTask task = p.Client.GetPartnerTask(SenderUser, Guid.Parse(Request["TaskID"].ToString()));
                    if (task != null)
                    {
                        SavePartnerTaskArgs args = new SavePartnerTaskArgs();
                        args.PartnerTask = task;
                        args.NextStep    = "待工厂拆单处理";
                        //args.CurrentStep = "设计方案";
                        args.Resource          = "店长组";                          //当前处理组
                        args.NextResource      = Request["UserCode"].ToString(); //下一个组
                        args.ActionRemarksType = "";
                        args.ActionRemarks     = Request["Remark"].ToString();
                        //args.Action = "分配量尺数据,给设计师设计方案";
                        args.Action = "酷家乐设计,提交拆单请求";

                        RoomDesigner roomDesiger = p.Client.GetRoomDesigner(SenderUser, Guid.Parse(Request["ReferenceID"].ToString()));
                        roomDesiger.Status = "C";//已分派
                        args.RoomDesigner  = roomDesiger;

                        p.Client.SavePartnerTask(SenderUser, args);
                        WriteSuccess();
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
コード例 #2
0
 public PartnerTask GetPartnerTask(Sender sender, Guid TaskID)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             PartnerTask obj = new PartnerTask();
             obj.TaskID = TaskID;
             if (op.LoadPartnerTaskByTaskID(obj) == 0)
             {
                 return(null);
             }
             return(obj);
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
コード例 #3
0
        public void SavePartnerTask(Sender sender, SavePartnerTaskArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    PartnerTask ta = new PartnerTask();
                    ta.TaskID = args.PartnerTask.TaskID;
                    if (op.LoadPartnerTaskByTaskID(ta) == 0)
                    {
                        #region 新任务
                        args.PartnerTask.TaskNo = ""; //设置任务编号
                        PartnerTaskStep ts = new PartnerTaskStep();
                        ts.StepID     = Guid.NewGuid();
                        ts.TaskID     = args.PartnerTask.TaskID;
                        ts.StepNo     = 1;
                        ts.StepName   = args.CurrentStep;
                        ts.Action     = args.Action;
                        ts.TargetStep = args.NextStep;

                        ts.Started    = DateTime.Now;
                        ts.StartedBy  = sender.UserCode + "." + sender.UserName;
                        ts.Ended      = ts.Started;
                        ts.EndedBy    = ts.StartedBy;
                        ts.Remark     = args.ActionRemarks;
                        ts.RemarkType = args.ActionRemarksType;

                        args.PartnerTask.StepNo     = ts.StepNo + 1;
                        args.PartnerTask.StepName   = ts.TargetStep;
                        args.PartnerTask.Created    = ts.Started;
                        args.PartnerTask.CreatedBy  = ts.StartedBy;
                        args.PartnerTask.Modified   = ts.Ended;
                        args.PartnerTask.ModifiedBy = ts.EndedBy;

                        op.InsertPartnerTask(args.PartnerTask);
                        op.InsertPartnerTaskStep(ts);
                        if (!string.IsNullOrEmpty(args.NextResource))
                        {
                            PartnerTaskResource newTR = new PartnerTaskResource();
                            newTR.TaskID    = ta.TaskID;
                            newTR.Resource  = args.NextResource;
                            newTR.Request   = "";
                            newTR.Started   = args.PartnerTask.Modified;
                            newTR.StartedBy = args.PartnerTask.ModifiedBy;
                            op.InsertPartnerTaskResource(newTR);
                        }
                        #endregion
                    }
                    else
                    {
                        #region 审批步骤任务
                        PartnerTaskResource tr = new PartnerTaskResource();
                        tr.TaskID   = args.PartnerTask.TaskID;
                        tr.Resource = args.Resource;
                        if (op.LoadPartnerTaskResourceByTaskID(tr) == 0)
                        {
                            throw new Exception(string.Format("任务资源不存在.TaskID:{0}, Resource:{1}", args.PartnerTask.TaskID, args.Resource));
                        }

                        PartnerTaskStep ts = new PartnerTaskStep();
                        ts.StepID   = Guid.NewGuid();
                        ts.TaskID   = ta.TaskID;
                        ts.StepNo   = ta.StepNo;
                        ts.StepName = ta.StepName;
                        ts.Action   = args.Action;
                        if (string.IsNullOrEmpty(args.NextStep))
                        {
                            ts.TargetStep = ta.StepName;
                        }
                        else
                        {
                            ts.TargetStep = args.NextStep;
                        }

                        ts.Started    = tr.Started;
                        ts.StartedBy  = tr.StartedBy;
                        ts.Ended      = DateTime.Now;
                        ts.EndedBy    = sender.UserCode + "." + sender.UserName;
                        ts.Remark     = args.ActionRemarks;
                        ts.RemarkType = args.ActionRemarksType;

                        args.PartnerTask.StepNo     = ts.StepNo + 1;
                        args.PartnerTask.StepName   = ts.TargetStep;
                        args.PartnerTask.Modified   = ts.Ended;
                        args.PartnerTask.ModifiedBy = ts.EndedBy;
                        op.UpdatePartnerTaskByTaskID(args.PartnerTask);
                        op.InsertPartnerTaskStep(ts);
                        if (string.IsNullOrEmpty(args.NextStep))
                        {
                            op.DeletePartnerTaskResourceByTaskID(tr.TaskID);
                        }
                        else
                        {
                            op.DeletePartnerTaskResourcesByTaskID(tr.TaskID);
                            if (!string.IsNullOrEmpty(args.NextResource))
                            {
                                PartnerTaskResource newTR = new PartnerTaskResource();
                                newTR.TaskID    = ta.TaskID;
                                newTR.Resource  = args.NextResource;
                                newTR.Request   = "";
                                newTR.Started   = ta.Modified;
                                newTR.StartedBy = ta.ModifiedBy;
                                op.InsertPartnerTaskResource(newTR);
                            }
                        }
                        #endregion
                    }

                    #region 量尺
                    if (args.RoomDesigner != null)
                    {
                        RoomDesigner obj = new RoomDesigner();
                        obj.DesignerID = args.RoomDesigner.DesignerID;
                        if (op.LoadRoomDesignerByDesignerID(obj) == 0)
                        {
                            args.RoomDesigner.Created    = DateTime.Now;
                            args.RoomDesigner.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            args.RoomDesigner.Modified   = DateTime.Now;
                            args.RoomDesigner.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            op.InsertRoomDesigner(args.RoomDesigner);
                        }
                        else
                        {
                            args.RoomDesigner.Modified   = DateTime.Now;
                            args.RoomDesigner.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                            op.UpdateRoomDesignerByDesignerID(args.RoomDesigner);
                        }
                    }

                    if (args.RoomDesignerFiles != null)
                    {
                        foreach (RoomDesignerFile file in args.RoomDesignerFiles)
                        {
                            RoomDesignerFile temp = new RoomDesignerFile();
                            temp.FileID = file.FileID;
                            if (op.LoadRoomDesignerFileByFileID(temp) == 0)
                            {
                                file.Created    = DateTime.Now;
                                file.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                file.Modified   = DateTime.Now;
                                file.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.InsertRoomDesignerFile(file);
                            }
                            else
                            {
                                file.Modified   = DateTime.Now;
                                file.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                                op.UpdateRoomDesignerFileByFileID(file);
                            }
                        }
                    }
                    #endregion

                    #region 方案
                    if (args.Solution != null)
                    {
                        Solution obj = new Solution();
                        obj.SolutionID = args.Solution.SolutionID;
                        if (op.LoadSolutionBySolutionID(obj) == 0)
                        {
                            args.Solution.Created    = DateTime.Now;
                            args.Solution.CreatedBy  = sender.UserCode + "." + sender.UserName;
                            args.Solution.Modified   = DateTime.Now;
                            args.Solution.ModifiedBy = sender.UserCode + "." + sender.UserName;
                            op.InsertSolution(args.Solution);
                        }
                        else
                        {
                            args.Solution.Modified   = DateTime.Now;
                            args.Solution.ModifiedBy = sender.UserCode + "." + sender.UserName;
                            op.UpdateSolutionBySolutionID(args.Solution);
                        }
                    }

                    if (args.SolutionFiles != null)
                    {
                        foreach (SolutionFile file in args.SolutionFiles)
                        {
                            SolutionFile obj = new SolutionFile();
                            obj.FileID = file.FileID;
                            if (op.LoadSolutionFileByFileID(obj) == 0)
                            {
                                file.Created    = DateTime.Now;
                                file.CreatedBy  = sender.UserCode + "." + sender.UserName;
                                file.Modified   = DateTime.Now;
                                file.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.InsertSolutionFile(file);
                            }
                            else
                            {
                                file.Modified   = DateTime.Now;
                                file.ModifiedBy = sender.UserCode + "." + sender.UserName;
                                op.UpdateSolutionFileByFileID(file);
                            }
                        }
                    }
                    #endregion

                    #region 方案报价
                    if (args.QuoteMain != null)
                    {
                        QuoteMain main = new QuoteMain();
                        main.QuoteID = args.QuoteMain.QuoteID;
                        if (op.LoadQuoteMainByQuoteID(main) == 0)
                        {
                            op.InsertQuoteMain(args.QuoteMain);
                        }
                        else
                        {
                            op.UpdateQuoteMainByQuoteID(args.QuoteMain);
                        }
                    }
                    if (args.QuoteDetails != null)
                    {
                        op.DeleteQuoteDetailsByQuoteID(args.QuoteMain.QuoteID);
                        foreach (QuoteDetail item in args.QuoteDetails)
                        {
                            op.InsertQuoteDetail(item);
                        }
                    }
                    #endregion
                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
コード例 #4
0
        public void UploadSolutionFile()
        {
            try
            {
                #region 文件上传
                Response.ContentType = "text/plain";
                Response.Charset     = "utf-8";
                HttpPostedFile file = null;
                try
                {
                    file = Request.Files["Filedata"];
                }
                catch
                {
                    throw new Exception("文件上传无效。");
                }
                if (string.IsNullOrEmpty(Request["ReferenceID"]))
                {
                    throw new Exception("参数无效。");
                }
                string PartnerID = Convert.ToString(CurrentUser.PartnerID);
                string TaskID    = Request["TaskID"];
                string FileType  = Request["FileType"];
                string SavePath  = DateTime.Now.ToString("yyyyMMdd") + "\\";

                //yyyyMMdd/PartnerID/文件类型(SolutionFile)/TaskID/FileName

                if (!string.IsNullOrEmpty(PartnerID))
                {
                    SavePath = Path.Combine(SavePath, PartnerID);
                }
                if (!string.IsNullOrEmpty(TaskID))
                {
                    SavePath = Path.Combine(SavePath, TaskID);
                }
                if (!string.IsNullOrEmpty(FileType))
                {
                    SavePath = Path.Combine(SavePath, FileType);
                }
                SavePath = Path.Combine(SavePath, Path.GetFileName(file.FileName));

                //通过SE上传文件,SE服务缺失,暂时注释
                //using (ProxySE ps = new ProxySE())
                //{
                //    byte[] buffer = new byte[file.ContentLength];
                //    Stream sr = file.InputStream;
                //    sr.Read(buffer, 0, file.ContentLength);
                //    ps.Client.UploadDoumentFile(SenderUser, SavePath, buffer);
                //}
                #endregion

                using (ProxyBE p = new ProxyBE())
                {
                    #region 方案文件
                    Solution solution = p.Client.GetSolutionByDesignerID(SenderUser, Guid.Parse(Request["ReferenceID"].ToString()));
                    SearchSolutionFileArgs fielArgs = new SearchSolutionFileArgs();
                    fielArgs.SolutionID = solution.SolutionID;
                    SearchResult sr      = p.Client.SearchSolutionFile(SenderUser, fielArgs);
                    List <Guid>  FileIDs = new List <Guid>();
                    if (sr.Total > 0)
                    {
                        foreach (DataRow row in sr.DataSet.Tables[0].Rows)
                        {
                            FileIDs.Add(new Guid(row["FileID"].ToString()));
                        }
                    }
                    if (solution == null)
                    {
                        throw new Exception("方案无效。");
                    }
                    if (FileIDs.Count > 0)
                    {
                        foreach (Guid item in FileIDs)
                        {
                            p.Client.DeleteSolutionFile(SenderUser, item);
                        }
                    }
                    SolutionFile solutionFile = new SolutionFile();
                    solutionFile.FileID     = Guid.NewGuid();
                    solutionFile.SolutionID = solution.SolutionID;
                    solutionFile.SourceID   = solution.SolutionID;
                    solutionFile.SourceType = "S";
                    solutionFile.Status     = "N";
                    solutionFile.FileName   = Path.GetFileName(SavePath);
                    solutionFile.FileUrl    = SavePath;

                    SaveSolutionFileArgs solutionFileAgrs = new SaveSolutionFileArgs();
                    solutionFileAgrs.SolutionFile = solutionFile;
                    p.Client.SaveSolutionFile(SenderUser, solutionFileAgrs);
                    #endregion

                    #region 任务流程
                    PartnerTask task = p.Client.GetPartnerTask(SenderUser, Guid.Parse(TaskID));
                    if (task != null)
                    {
                        SavePartnerTaskArgs taskArgs = new SavePartnerTaskArgs();
                        taskArgs.PartnerTask       = task;
                        task.StepName              = "生成报价明细";
                        taskArgs.NextStep          = "生成报价明细";
                        taskArgs.Resource          = CurrentUser.UserCode; //当前处理组
                        taskArgs.NextResource      = "CPT";                //下一个组
                        taskArgs.Action            = "设计师重新上传方案";
                        taskArgs.ActionRemarksType = "";
                        taskArgs.ActionRemarks     = "设计师重新上传方案";
                        p.Client.SavePartnerTask(SenderUser, taskArgs);
                        WriteSuccess();
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
コード例 #5
0
        public void SaveRoomDesigner()
        {
            using (ProxyBE p = new ProxyBE())
            {
                try
                {
                    #region RoomDesigner

                    if (parm.CustomerID == Guid.Empty)
                    {
                        throw new Exception("请选择客户。");
                    }

                    RoomDesigner roomdesigner = p.Client.GetRoomDesigner(null, parm.DesignerID);
                    if (roomdesigner == null)
                    {
                        roomdesigner            = new RoomDesigner();
                        roomdesigner.DesignerID = parm.DesignerID;
                    }
                    roomdesigner.CustomerID           = parm.CustomerID;
                    roomdesigner.Designer             = CurrentUser.UserID;//经销商ID
                    roomdesigner.Designed             = parm.Designed;
                    roomdesigner.Rooms                = parm.Rooms;
                    roomdesigner.SittingAndDiningRoom = parm.SittingAndDiningRoom;
                    roomdesigner.TotalAreal           = parm.TotalAreal;
                    roomdesigner.FamilyMembers        = parm.FamilyMembers;
                    roomdesigner.Budget               = parm.Budget;
                    roomdesigner.VillageName          = parm.VillageName;
                    roomdesigner.Building             = parm.Building;
                    roomdesigner.Unit       = parm.Unit;
                    roomdesigner.RoomNo     = parm.RoomNo;
                    roomdesigner.Color      = parm.Color;
                    roomdesigner.Style      = parm.Style;
                    roomdesigner.Status     = "N";//待分派
                    roomdesigner.Remark     = parm.Remark;
                    roomdesigner.DesignerNo = "0";

                    //产生任务
                    PartnerTask task = new PartnerTask();
                    task.ReferenceID = roomdesigner.DesignerID;
                    task.TaskID      = Guid.NewGuid();
                    task.TaskNo      = p.Client.GetTaskNo(SenderUser);
                    task.TaskType    = "方案设计"; //任务类型
                    task.PartnerID   = CurrentUser.PartnerID;
                    task.StepName    = "新建量尺"; //步骤
                    task.StepNo      = 1;

                    #endregion

                    #region RoomDesignerFile
                    List <RoomDesignerFile> list   = new List <RoomDesignerFile>();
                    RoomDesignerFile        rdFile = null;

                    IList <filemodel> ArrayPath = new List <filemodel>();
                    if (!string.IsNullOrEmpty(Request["RoomDesignerFiles"]))
                    {
                        ArrayPath = JSONHelper.JSONToObject <IList <filemodel> >(Request["RoomDesignerFiles"]);
                    }
                    //PartnerID/yyyyMM/文件类型(RoomDesignerFile)/DesignerID/FileName

                    string ServerPath = Server.MapPath("/");
                    if (ArrayPath.Count > 0)
                    {
                        for (var i = 0; i < ArrayPath.Count; i++)
                        {
                            string filePath = System.Web.HttpUtility.UrlDecode(ArrayPath[i].filePath);
                            rdFile            = new RoomDesignerFile();
                            rdFile.FileID     = Guid.NewGuid();
                            rdFile.DesignerID = roomdesigner.DesignerID;
                            rdFile.Title      = "";
                            rdFile.FileName   = Path.GetFileName(ServerPath + filePath);
                            rdFile.Remark     = "";
                            rdFile.FileURL    = filePath;
                            //string SavePath = DateTime.Now.ToString("yyyyMM");
                            //SavePath = Path.Combine(SavePath, CurrentUser.PartnerID.ToString());
                            //SavePath = Path.Combine(SavePath, "RoomDesignerFile");
                            //SavePath = Path.Combine(SavePath, roomdesigner.DesignerID.ToString());
                            //SavePath = Path.Combine(SavePath, rdFile.FileName);
                            //rdFile.FileURL = SavePath;
                            //UploadFile(RoomDesignerFileUrl, SavePath);
                            list.Add(rdFile);
                        }
                    }
                    #endregion

                    #region 任务流程
                    SavePartnerTaskArgs args = new SavePartnerTaskArgs();
                    args.RoomDesigner = roomdesigner;
                    args.PartnerTask  = task;
                    args.NextResource = "店长组"; //谁处理
                    //args.NextStep = "分派设计师";
                    args.NextStep          = "待酷家乐设计";
                    args.CurrentStep       = "新建量尺";
                    args.Resource          = ""; //分配者
                    args.ActionRemarksType = ""; //意见类型
                    args.ActionRemarks     = ""; //审批意见
                    //args.Action = "提交量尺数据,给店长分配任务";
                    args.Action = "酷家乐设计,提交工厂拆单";

                    args.RoomDesignerFiles = list;
                    p.Client.SavePartnerTask(SenderUser, args);
                    WriteSuccess();
                    #endregion
                }
                catch (Exception ex)
                {
                    WriteError(ex.Message, ex);
                }
            }
        }