Ejemplo n.º 1
0
        public CopyStatusViewModel(string _varProcess, string _oldPartNo, string _oldRouteNo, string _oldSeqNo = "", string _oldCC = "", string _oldSH = "")
        {
            UserInformation user = (UserInformation)App.Current.Properties["userinfo"];

            userinformation = user;

            OldPartNo  = _oldPartNo;
            OldRouteNo = _oldRouteNo;
            oldSeqNo   = _oldSeqNo;
            oldShNo    = _oldSH;
            OldCCSno   = _oldCC;

            // NewPartNo = _newPartNo;
            VarProcess            = _varProcess;
            this.copyClickCommand = new DelegateCommand(this.CopyPartNo);
            this._onCloseCommand  = new DelegateCommand(this.Close);
            cpyBll     = new CopyStatusBLL(userinformation);
            cpyProcess = new CopyProcess(userinformation);
            LoadData();
            this.onCheckBoxClicked = new DelegateCommand(this.EnableDisableTextBoxs);
            this.selectChangeComboCommandNewPartNo   = new DelegateCommand(this.SelectDataRowNewPart);
            this.selectChangeComboCommandNewRoute    = new DelegateCommand(this.SelectDataRowNewRoute);
            this.selectChangeComboCommandNewSequence = new DelegateCommand(this.SelectDataRowNewSequence);
            //if (IschkControlPlan == true && IschkDrawings == false && ischkPrdMast == false && IschkProcessSheet == false && IschkToolSchedule == false)
            //{
            //    IsNewPartNoReadonly = true;
            //    ButtonVisibleNewPartNumber = Visibility.Visible;
            //    IsNewRouteNoReadonly = true;
            //    ButtonVisibleNewRouteNumber = Visibility.Visible;
            //    IsNewSeqNoReadonly = true;
            //    ButtonVisibleNewSeqNumber = Visibility.Visible;
            //    SetdropDownItems();
            //    NewPartNoDetails = cpyBll.GetPartNoDetails(NewPartNoDetails);
            //}
        }
Ejemplo n.º 2
0
        private void CopyPartNo()
        {
            Progress.ProcessingText = PDMsg.Copy;
            Progress.Start();

            cpyBll     = new CopyStatusBLL(userinformation);
            cpyProcess = new CopyProcess(userinformation);
            DataValidation();

            Progress.End();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //Composition Root
            var reader = new ConsoleReader();
            //var writer = new ConsoleWriter();
            var writer      = new FileWriter("result.txt");
            var copyProcess = new CopyProcess(reader, writer);

            // Run programm
            copyProcess.Copy();
            writer.Dispose();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var reader = new ConsoleReader();
            var writer = new ConsoleWriter();
            //var writer = new FileWriter("Text.txt");
            var copyProcess = new CopyProcess(reader, writer);

            //Run the actual program
            copyProcess.Execute();


            //writer.Dispose();  //not neccessary for console writer
        }
Ejemplo n.º 5
0
        async Task CopyUploadedFiles(CopyProcess process)
        {
            var copyTasks = new List <Task>();

            foreach (var key in new[] { "UploadFolder", "UploadFolder.Secure" })
            {
                var source = Config.Get(key);
                if (source.IsEmpty())
                {
                    Debug.WriteLine("Destination directory not configured in App.Config for key: " + key);
                    continue;
                }

                var folder = Config.Get(key);
                if (folder.ToCharArray()[0] == '/')
                {
                    folder = folder.Substring(1);
                }

                if (process == CopyProcess.Restore)
                {
                    source = Path.Combine(SnapshotsDirectory.ToString(), folder);
                    if (!Directory.Exists(source))
                    {
                        continue;
                    }

                    var dest = AppDomain.CurrentDomain.WebsiteRoot().GetSubDirectory(Config.Get(key));
                    copyTasks.Add(new DirectoryInfo(source).CopyTo(dest, overwrite: true));
                }
                else if (process == CopyProcess.Backup)
                {
                    source = AppDomain.CurrentDomain.WebsiteRoot().GetSubDirectory(source).FullName;
                    if (!Directory.Exists(source))
                    {
                        continue;
                    }
                    copyTasks.Add(new DirectoryInfo(source).CopyTo(Path.Combine(SnapshotsDirectory.ToString(), folder), overwrite: true));
                }
            }

            await Task.WhenAll(copyTasks);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var addNew = new AddNewCopyProcess();

            if (addNew.ShowDialog() == true)
            {
                var copyProcess = new CopyProcess(new PathCollection(addNew.SourcePath), addNew.DestPath
#if DEBUG
                                                  , null
#endif
                                                  )
                {
                    WorkerReportsProgress = true, WorkerSupportsCancellation = true
                };

                Items.Add(copyProcess);

                copyProcess.RunWorkerAsync();
            }
        }
Ejemplo n.º 7
0
        void CopyUploadedFiles(CopyProcess process)
        {
            var copyActions = new List <Action>();

            foreach (var key in new[] { "UploadFolder", "UploadFolder.Secure" })
            {
                var source = Config.Get(key);
                if (source.IsEmpty())
                {
                    Debug.WriteLine("Destination directory not configured in App.Config for key: " + key);
                    continue;
                }

                var folder = Config.Get(key);
                if (folder.ToCharArray()[0] == '/')
                {
                    folder = folder.Substring(1);
                }

                if (process == CopyProcess.Restore)
                {
                    source = Path.Combine(SnapshotsDirectory.ToString(), folder);
                    if (!Directory.Exists(source))
                    {
                        continue;
                    }
                    copyActions.Add(delegate { new DirectoryInfo(source).CopyTo(AppDomain.CurrentDomain.GetPath(Config.Get(key)), overwrite: true); });
                }
                else if (process == CopyProcess.Backup)
                {
                    source = AppDomain.CurrentDomain.GetPath(source);
                    if (!Directory.Exists(source))
                    {
                        continue;
                    }
                    copyActions.Add(delegate { new DirectoryInfo(source).CopyTo(Path.Combine(SnapshotsDirectory.ToString(), folder), overwrite: true); });
                }
            }

            copyActions.AsParallel().Do(a => a?.Invoke());
        }
Ejemplo n.º 8
0
 private void CopyFiles(string source, string destination)
 {
     try
     {
         string component = Context.ComponentFullName;
         Log.WriteStart("Copying files");
         Log.WriteInfo(string.Format("Copying files from \"{0}\" to \"{1}\"", source, destination));
         //showing copy process
         CopyProcess process = new CopyProcess(GetProgressObject(), source, destination);
         process.Run();
         Log.WriteEnd("Copied files");
         InstallLog.AppendLine(string.Format("- Copied {0} files", component));
         // rollback
         RollBack.RegisterDirectoryAction(destination);
     }
     catch (Exception ex)
     {
         if (Utils.IsThreadAbortException(ex))
             return;
         Log.WriteError("Copy error", ex);
         throw;
     }
 }
Ejemplo n.º 9
0
        public void DataValidation()
        {
            try
            {
                DataTable dtRecordCount;
                int       estcount   = 0;
                int       actcount   = 0;
                bool      dataCopied = false;

                IsNewPartNoReadonly        = false;
                ButtonVisibleNewPartNumber = Visibility.Collapsed;

                imgPrdMaster           = Visibility.Hidden;
                ImgProcessSheetHeader  = Visibility.Hidden;
                ImgProcessSheet        = Visibility.Hidden;
                ImgProcessSheetCC      = Visibility.Hidden;
                ImgToolScheduleHeader  = Visibility.Hidden;
                ImgToolScheduleDetails = Visibility.Hidden;
                imgControlPlan         = Visibility.Hidden;
                imgProductDrawing      = Visibility.Hidden;
                imgSequenceDrawing     = Visibility.Hidden;

                if (OldPartNo.Trim() == "")
                {
                    ShowInformationMessage(PDMsg.NotEmpty("Old PartNo"));
                    return;
                }
                else
                {
                    dtRecordCount = cpyBll.GetRecordCount("part_no", "prd_mast", OldPartNo);
                    if (dtRecordCount.Rows.Count == 0)
                    {
                        ShowInformationMessage(PDMsg.EnterValid("Old PartNo"));
                        return;
                    }
                }

                if (NewPartNo.Trim() == "")
                {
                    ShowInformationMessage(PDMsg.NotEmpty("New PartNo"));
                    return;
                }
                else
                {
                    if (IschkPrdMast == false)
                    {
                        dtRecordCount = cpyBll.GetRecordCount("part_no", "prd_mast", NewPartNo);
                        if (dtRecordCount.Rows.Count == 0)
                        {
                            ShowInformationMessage(PDMsg.EnterValid("New PartNo"));
                            return;
                        }
                    }
                }

                //if (newPartNo.Trim() == oldPartNo.Trim())
                //{
                //    ShowInformationMessage("Old Part No. and New Part No. Should not be Same!");
                //    return;
                //}

                if (IschkProcessSheet == true)
                {
                    if (cpyProcess.RecordsCountProcessSheet(OldPartNo, OldRouteNo.ToIntValue(), OldSeqNo.ToDecimalValue(), OldCCSno.ToDecimalValue(), OldShNo.ToDecimalValue()) == 0)
                    {
                        ShowInformationMessage("Process sheet Data not available to Copy.");
                        return;
                    }
                }

                if (IschkToolSchedule == true)
                {
                    if (cpyProcess.RecordsCountToolSched(OldPartNo, OldRouteNo.ToIntValue(), OldSeqNo.ToDecimalValue(), OldCCSno.ToDecimalValue(), OldShNo.ToDecimalValue()) == 0)
                    {
                        IschkToolSchedule = false;
                        ShowInformationMessage("Tool schedule Data not available to Copy.");
                        //return;
                    }
                }

                if (IschkControlPlan == true)
                {
                    if (VarProcess == "ProductMaster" && NewRouteNo.Trim() == "" && OldRouteNo.Trim() == "")
                    {
                        newRouteNo = oldRouteNo = Convert.ToString(cpyProcess.GetCurrentProcessByPartNumber(new PROCESS_MAIN()
                        {
                            PART_NO = oldPartNo.Trim()
                        }).ROUTE_NO);
                        if (NewRouteNo.Trim() == "" && OldRouteNo.Trim() == "" || (NewRouteNo.Trim() == "-999999" && OldRouteNo.Trim() == "-999999"))
                        {
                            ShowInformationMessage(PDMsg.DoesNotExists("Current Process"));
                            return;
                        }
                    }

                    if (NewRouteNo.Trim() == "" && OldRouteNo.Trim() == "")
                    {
                        ShowInformationMessage(PDMsg.NormalString("Enter New Process No and Old Process No"));
                        return;
                    }
                    if (NewRouteNo.Trim() == "" && OldRouteNo.Trim() != "")
                    {
                        ShowInformationMessage(PDMsg.NormalString("Enter New Process No"));
                        return;
                    }
                    if (NewRouteNo.Trim() != "" && OldRouteNo.Trim() == "")
                    {
                        ShowInformationMessage(PDMsg.NormalString("Enter Old Process No"));
                        return;
                    }
                }
                else
                {
                    if (NewRouteNo.Trim() == "" && OldRouteNo.Trim() != "")
                    {
                        ShowInformationMessage(PDMsg.NormalString("Enter New Process No or remove Old Process No"));
                        return;
                    }
                }
                if (NewSeqNo.Trim() == "" && OldSeqNo.Trim() != "")
                {
                    ShowInformationMessage(PDMsg.NormalString("Enter New Sequence No or remove Old Sequence No"));
                    return;
                }

                if (NewCCSno.Trim() == "" && OldCCSno.Trim() != "")
                {
                    ShowInformationMessage(PDMsg.NormalString("Enter New Cost Centre no or remove Old Cost Centre No"));
                    return;
                }

                if (NewCCSno.Trim() == "" && OldCCSno.Trim() != "")
                {
                    ShowInformationMessage(PDMsg.NormalString("Enter New Cost Centre no or remove Old Cost Centre No"));
                    return;
                }

                int x = 0;

                if (IschkPrdMast == true)
                {
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_prdMaster(OldPartNo, NewPartNo);
                    if (x == 1)
                    {
                        imgPrdMaster = Visibility.Visible;
                        dataCopied   = true;
                        actcount     = actcount + 1;
                    }
                }
                if (IschkProcessSheet == true)
                {
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_Process_main(OldPartNo, NewPartNo, OldRouteNo, NewRouteNo);
                    if (x == 1)
                    {
                        ImgProcessSheetHeader = Visibility.Visible;
                        dataCopied            = true;
                        actcount = actcount + 1;
                    }
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_Process_sheet(OldPartNo, NewPartNo, OldRouteNo, NewRouteNo, OldSeqNo, NewSeqNo);
                    if (x == 1)
                    {
                        ImgProcessSheet = Visibility.Visible;
                        dataCopied      = true;
                        actcount        = actcount + 1;
                    }
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProcessCostCenter(OldPartNo, NewPartNo, OldRouteNo.ToIntValue(), NewRouteNo.ToIntValue(), OldSeqNo.ToDecimalValue(), NewSeqNo.ToDecimalValue(), OldCCSno.ToIntValue(), NewCCSno.ToIntValue());
                    if (x == 1)
                    {
                        ImgProcessSheetCC = Visibility.Visible;
                        dataCopied        = true;
                        actcount          = actcount + 1;
                    }
                }
                if (IschkToolSchedule == true)
                {
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_Tool_Sched_Main(oldPartNo, NewPartNo, OldRouteNo, NewRouteNo, OldSeqNo, NewSeqNo, OldCCSno, NewCCSno, OldShNo, NewShNo);
                    if (x == 1)
                    {
                        ImgToolScheduleHeader = Visibility.Visible;
                        dataCopied            = true;
                        actcount = actcount + 1;
                    }
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_Tool_Sched_Sub(oldPartNo, NewPartNo, OldRouteNo, NewRouteNo, OldSeqNo, NewSeqNo, OldCCSno, NewCCSno, OldShNo, NewShNo);
                    if (x == 1)
                    {
                        ImgToolScheduleDetails = Visibility.Visible;
                        dataCopied             = true;
                        actcount = actcount + 1;
                    }
                }
                if (IschkControlPlan == true)
                {
                    //  x = cpyProcess.CopyProcessSheet(OldPartNo, NewPartNo, OldRouteNo.ToIntValue(), NewRouteNo.ToIntValue(), OldSeqNo.ToDecimalValue(), NewSeqNo.ToDecimalValue());
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_PCCS(OldPartNo, NewPartNo, OldRouteNo, NewRouteNo, OldSeqNo, NewSeqNo);
                    ButtonVisibleNewPartNumber = Visibility.Collapsed;
                    if (x == 1)
                    {
                        imgControlPlan = Visibility.Visible;
                        dataCopied     = true;
                        actcount       = actcount + 1;
                    }
                    else if (x == -1)
                    {
                        cpyProcess = new CopyProcess(userinformation);
                        //  ShowInformationMessage("Matching Sequence No is not available in Process Sheet");
                    }
                }

                if (ischkDrawings == true)
                {
                    // x = cpyProcess.CopyProductData_PROD_DRAWING(OldPartNo, NewPartNo);
                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_PRD_DRAWING(OldPartNo, NewPartNo, 0);
                    if (x == 1)
                    {
                        imgProductDrawing = Visibility.Visible;
                        dataCopied        = true;
                        actcount          = actcount + 1;
                    }

                    estcount = estcount + 1;
                    x        = cpyProcess.CopyProductData_PRD_DRAWING(OldPartNo, NewPartNo, 1);
                    if (x == 1)
                    {
                        imgSequenceDrawing = Visibility.Visible;
                        dataCopied         = true;
                        actcount           = actcount + 1;
                    }
                }

                if (estcount > 0)
                {
                    if (estcount == actcount)
                    {
                        ShowInformationMessage("Data successfully copied!");
                    }
                    else if (actcount > 0)
                    {
                        ShowInformationMessage("Partial data successfully copied!");
                    }
                    else
                    {
                        ShowInformationMessage("Data not copied!");
                    }
                }
                else
                {
                    ShowInformationMessage("Data not copied!");
                }
                //if (dataCopied == true)
                //{
                //    ShowInformationMessage("Data successfully copied!");
                //}

                //         private PCCS _activeEntity = null;
                //public PCCS ActiveEntity
                //{
                //    get
                //    {
                //        return _activeEntity;
                //    }
                //    set
                //    {
                //        _activeEntity = value;
                //        NotifyPropertyChanged("ActiveEntity");
                //    }
                //}
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
        }