Example #1
0
        public async Task Create(CreateWorkOrderDto input)
        {
            var @workorder = input.MapTo <WorkOrderHeader>();

            @workorder = WorkOrderHeader.Create(AbpSession.GetTenantId(), input.WorkOrderNo, input.StartDate, input.EndDate,
                                                input.Status, input.Priority, input.Remark, input.StyleId, input.StyleNo);
            int i = 0;
            await _workorderRepository.InsertAsync(@workorder);
        }
Example #2
0
        public DataValidatorReturn Delete(string clientCode)
        {
            DVR = MethodHelper.IsParameterEmpty("ClientCode", clientCode);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            DataValidatorReturn dvr = new DataValidatorReturn();

            dvr = Find(clientCode);

            if (dvr.ItemFound == false)
            {
                DVR.IsValid    = false;
                DVR.ReturnText = clientCode + " not found.";
                DVR.ItemFound  = false;
                return(DVR);
            }

            using (var context = new WorkOrderLogEntities())
            {
                try
                {
                    int workOrderHeaderCount = 0;

                    //Delete foreign relationships etc.
                    var workOrderHeaders = context.WorkOrderHeaders.Where(x => x.ClientCode == clientCode).ToList();
                    workOrderHeaderCount = workOrderHeaders.Count();

                    for (int i = 0; i < workOrderHeaderCount; i++)
                    {
                        WorkOrderHeader workOrderHeader = workOrderHeaders[i];
                        context.WorkOrderHeaders.Remove(workOrderHeader);
                    }

                    Client client = context.Clients.Where(x => x.ClientCode == clientCode).FirstOrDefault();

                    context.Clients.Remove(client);

                    context.SaveChanges();

                    DVR.IsValid    = true;
                    DVR.ReturnText = clientCode + " Removed Successfully." + Environment.NewLine + workOrderHeaderCount.ToString() +
                                     " Work Order Headers Removed successfully.";
                }
                catch (Exception exception)
                {
                    DVR.IsValid   = false;
                    DVR.ErrorText = exception.Message;
                }
            }

            return(DVR);
        }
Example #3
0
        public DataValidatorReturn Create(int workOrderID, string clientCode)
        {
            DVR = MethodHelper.IsGreaterThanZero("Work Order Number", workOrderID);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            DVR = MethodHelper.IsParameterEmpty("Client Code", clientCode);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            if (Find(workOrderID).ItemFound)
            {
                DVR.IsValid    = false;
                DVR.ReturnText = "Work Order # " + workOrderID.ToString() + " already exists.";
                DVR.ItemFound  = true;
                return(DVR);
            }

            using (var context = new WorkOrderLogEntities())
            {
                WorkOrderHeader workderOrderHeader = new WorkOrderHeader()
                {
                    WOHdrID     = workOrderID,
                    ClientCode  = clientCode,
                    CreatedDate = DateTime.Now.ToLocalTime(),
                    CreatedBy   = "SYSTEM"
                };

                try
                {
                    context.WorkOrderHeaders.Add(workderOrderHeader);
                    context.SaveChanges();
                    DVR.IsValid    = true;
                    DVR.ReturnText = "Work Order #" + workOrderID.ToString() + " Added to the Database.";
                    DVR.ReturnType = workderOrderHeader;
                }
                catch (Exception exception)
                {
                    DVR.IsValid    = false;
                    DVR.ReturnText = exception.Message;
                }
            }

            return(DVR);
        }
Example #4
0
 public int Delete(WorkOrderHeader _WorkOrderHeader)
 {
     return(WorkOrderHeaderDaoRepository.Delete(_WorkOrderHeader));
 }
Example #5
0
 public int Update(WorkOrderHeader _WorkOrderHeader)
 {
     return(WorkOrderHeaderDaoRepository.Update(_WorkOrderHeader));
 }
Example #6
0
 public int Insert(WorkOrderHeader _WorkOrderHeader)
 {
     return(WorkOrderHeaderDaoRepository.Insert(_WorkOrderHeader));
 }
Example #7
0
 public bool Validate(WorkOrderHeader _WorkOrderHeader, out List <string> lstMessages)
 {
     return(WorkOrderHeaderDaoRepository.Validate(_WorkOrderHeader, out lstMessages));
 }
        public DataValidatorReturn Create(int workOrderID, int itemNumber, int activityID)
        {
            WorkOrderHeader workOrderHeader = null;

            DVR = MethodHelper.IsGreaterThanZero("Work Order Number", workOrderID);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            DVR = MethodHelper.IsGreaterThanZero("Item Number", itemNumber);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            DVR = MethodHelper.IsGreaterThanZero("Activity ID", activityID);

            if (DVR.IsValid == false)
            {
                return(DVR);
            }

            if (Find(workOrderID, itemNumber, activityID).ItemFound)
            {
                DVR.IsValid    = false;
                DVR.ReturnText = "Work Order Detail # " + workOrderID.ToString() + " already exists.";
                DVR.ItemFound  = true;
                return(DVR);
            }

            BO_WorkOrderHeader bo_WorkOrderHeader = new BO_WorkOrderHeader();

            DVR = bo_WorkOrderHeader.Find(workOrderID);

            if (DVR.ItemFound == false)
            {
                DVR.IsValid    = false;
                DVR.ReturnText = "Work Order Header # " + workOrderID.ToString() + " doesn't exist.";
                DVR.ItemFound  = true;
                return(DVR);
            }
            else
            {
                workOrderHeader = DVR.ReturnType as WorkOrderHeader;
            }

            using (var context = new WorkOrderLogEntities())
            {
                // Find the work Order Header here.


                WorkOrderDetail workOrderDetail = new WorkOrderDetail()
                {
                    WOHdrID    = workOrderID,
                    ItemNumber = itemNumber,
                    ActivityID = activityID
                };

                try
                {
                    int activityTypeID = 2;

                    context.WorkOrderDetails.Add(workOrderDetail);

                    context.SaveChanges();

                    //Once we have created a work order detail need to look for the
                    //Activity using the activity Id, and then get the activityTypeId
                    //Go to the sourcescripthdr table and get the sourcescripthdrid
                    //and use the info from the sourcescriptdtl table to create
                    //WorkOrderDtlScript records also need to create these actual files
                    //by retrieving the source items and pasting to the new files.
                    BO_SourceScriptHdr  bo_SourceScriptHdr  = new BO_SourceScriptHdr();
                    DataValidatorReturn dataValidatorReturn = bo_SourceScriptHdr.Find(activityTypeID);

                    if (dataValidatorReturn.ItemFound)
                    {
                        var sourceScriptHdr  = dataValidatorReturn.ReturnType as SourceScriptHdr;
                        var sourceScriptDtls = sourceScriptHdr.SourceScriptDtls;

                        if (sourceScriptDtls.Any())
                        {
                            string sourceFileFullPath = string.Empty;
                            string sourceFile         = string.Empty;
                            string sourceClientCode   = string.Empty;
                            string destFile           = string.Empty;
                            string destClientCode     = string.Empty;
                            string destFileFullPath   = string.Empty;
                            string destFolder         = string.Empty;
                            string sourceFileContents = string.Empty;
                            string destFileContents   = string.Empty;

                            foreach (SourceScriptDtl sourceScriptDtl in sourceScriptDtls)
                            {
                                // Set the source File.
                                sourceFile         = sourceScriptDtl.SourceFile;
                                sourceClientCode   = sourceScriptDtl.ClientCode;
                                sourceFileFullPath = Path.Combine(sourceScriptDtl.Client.ClientFolder, sourceScriptDtl.SourceFile);

                                destClientCode   = workOrderHeader.ClientCode;
                                destFile         = sourceFile.Replace(sourceClientCode, destClientCode);
                                destFolder       = workOrderHeader.Client.ClientFolder;
                                destFileFullPath = Path.Combine(destFolder, destFile);

                                // Logic change instead of copying, replace text required
                                sourceFileContents = File.ReadAllText(sourceFileFullPath);
                                destFileContents   = sourceFileContents.Replace(sourceClientCode, destClientCode);
                                destFileContents   = destFileContents.Replace("0", workOrderHeader.WOHdrID.ToString());

                                File.WriteAllText(destFileFullPath, destFileContents);

                                //Create WorkOrderDetailScripts foreach script created.
                                BO_WorkOrderDtlScripts bo_WorkOrderDtlScripts = new BO_WorkOrderDtlScripts();
                                bo_WorkOrderDtlScripts.Create(workOrderDetail.WODtlId, destFile);
                            }

                            context.SaveChanges();
                        }
                    }


                    DVR.IsValid    = true;
                    DVR.ReturnText = "Work Order Detail #" + workOrderID.ToString() + " Added to the Database.";
                    DVR.ReturnType = workOrderDetail;
                }
                catch (Exception exception)
                {
                    DVR.IsValid    = false;
                    DVR.ReturnText = exception.Message;
                }
            }

            return(DVR);
        }