Beispiel #1
0
        public HttpResponseMessage PutJob(int nID, JobUploadApiDTO job)
        {
            try
            {
                //HttpResponseMessage responseMessage = getAPIAuthorizationMessage();
                //if (responseMessage != null)
                //    return responseMessage;

                HttpResponseMessage responseMessage = getTokenAuthorizationMessage();
                if (responseMessage != null)
                    return responseMessage;

                if (nID == job.nID)
                {
                    IJobService jobService = (new ServiceFactory(ApplicationSetting.Current.DefaultConnectionString)).GetJobService();
                    jobService.PutApiEditJob(nID, job);
                }
                return CreateEmptyMessage();
            }
            catch (Exception exception)
            {
                return CreateServerErrorMessages(exception);
            }
        }
Beispiel #2
0
        public void PutApiEditJob(int nID, JobUploadApiDTO job)
        {
            using (var ds = new DataService(this.connectionString, this.consumerInfo))
            {
                CrmtOrder jobOrder = null;
                try
                {
                    jobOrder = ds.CrmtOrder.GetAllNotDelete().Where(x => x.nID == nID).FirstOrDefault();

            //        \{         # Escaped curly parentheses, means "starts with a '{' character"
            //        (          # Parentheses in a regex mean "put (capture) the stuff
            //                   #     in between into the Groups array"
            //           [^}]    # Any character that is not a '}' character
            //           *       # Zero or more occurrences of the aforementioned "non '}' char"
            //        )          # Close the capturing group
            //        \}
                    if (jobOrder.sFault.Contains("[") && jobOrder.sFault.Contains("]") && jobOrder.nIsOrder == 1)
                    {
                        Regex sFaultRegex = new Regex(@"\[([^\]]+)\]");
                        jobOrder.sFault = sFaultRegex.Replace(job.sFault, "[完成保養]");
                    }
                    else
                    {
                        jobOrder.sFault = job.sFault;
                    }
                    jobOrder.nOrderStatus = 3;
                    jobOrder.sRemark = job.sRemark;
                    jobOrder.sReport = job.sReport;
                    jobOrder.sRepair = job.sRepair;
                    jobOrder.dCompletionDate = job.dCompletionDate;
                    jobOrder.tActualStartTime = job.tActualStartTime;
                    jobOrder.tActualEndTime = job.tActualEndTime;
                    jobOrder.nAdHocTechnicianID = job.nAdHocTechnicianID;
                    jobOrder.dReportSignDate = job.dReportSignDate;
                    jobOrder.sReportOpinion = job.sReportOpinion;
                    jobOrder.sChecklistOpinion = job.sChecklistOpinion;
                    jobOrder.sReceipt = job.sReceipt;
                    jobOrder.nLanguage = job.nLanguage;
                    jobOrder.dLastUpdate = DateTime.Now;
                    ds.CrmtOrder.Update(jobOrder);
                    ds.SaveChanges();
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
        }