Esempio n. 1
0
        public ActionResult DeleteProcess(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Invalid selection";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                var delStatus = new ProcessServices().DeleteProcess(id);
                if (delStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Process could not be deleted. Please try again later.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Process Information was successfully deleted";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
 public RemoteBrokerFixture()
 {
     _fileSystem     = new WindowsFileSystem();
     _installations  = new RInstallation();
     _processService = new ProcessServices();
     _logFolder      = Path.Combine(DeployFilesFixture.TestFilesRoot, "Logs");
 }
Esempio n. 3
0
        public ActionResult EditProcess(ProcessObject process)
        {
            var gVal = new GenericValidator();

            try
            {
                //if (!ModelState.IsValid)
                //{
                //    gVal.Code = -1;
                //    gVal.Error = "Plese provide all required fields and try again.";
                //    return Json(gVal, JsonRequestBehavior.AllowGet);
                //}

                if (string.IsNullOrEmpty(process.Name.Trim()))
                {
                    gVal.Code  = -1;
                    gVal.Error = "Please provide Process.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_Process"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldProcess = Session["_Process"] as ProcessObject;

                if (oldProcess == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                oldProcess.Name = process.Name.Trim();

                var docStatus = new ProcessServices().UpdateProcess(oldProcess);
                if (docStatus < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Process information could not be updated. Please try again later";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = oldProcess.Id;
                gVal.Error = "Process information was successfully updated";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Code  = -1;
                gVal.Error = "Process information could not be updated. Please try again later";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public void TestSimpleProcessStart()
        {
            LogStart("TestSimpleProcessStart");

            var source = new CancellationTokenSource();
            var task   = ProcessServices.RunProcess("helloOutput.bat", "", source.Token);//.Wait(TimeSpan.FromSeconds(1));

            task.Wait(TimeSpan.FromSeconds(1));
            Assert.IsTrue(task.Result.ExitCode == 66);
            Assert.IsTrue(task.Result.Output.Trim() == "Hello output!");
            Assert.IsTrue(task.Result.Error.Trim() == "Hello error!");
        }
Esempio n. 5
0
        public ActionResult GetProcessObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <ProcessObject> filteredParentMenuObjects;
                var countG = 0;

                var pagedParentMenuObjects = GetProcesss(param.iDisplayLength, param.iDisplayStart, out countG);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredParentMenuObjects = new ProcessServices().Search(param.sSearch);
                }
                else
                {
                    filteredParentMenuObjects = pagedParentMenuObjects;
                }

                if (!filteredParentMenuObjects.Any())
                {
                    return(Json(new List <ProcessObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <ProcessObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.Name : c.ImportStageName);

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredParentMenuObjects = sortDirection == "desc" ? filteredParentMenuObjects.OrderBy(orderingFunction) : filteredParentMenuObjects.OrderByDescending(orderingFunction);

                var displayedPersonnels = filteredParentMenuObjects;

                var result = from c in displayedPersonnels
                             select new[] { Convert.ToString(c.Id), c.Name, c.ImportStageName };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = countG,
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <ProcessObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 6
0
        public ActionResult AddProcess(ProcessObject process)
        {
            var gVal = new GenericValidator();

            try
            {
                //if (!ModelState.IsValid)
                //{
                //    gVal.Code = -1;
                //    gVal.Error = "Plese provide all required fields and try again.";
                //    return Json(gVal, JsonRequestBehavior.AllowGet);
                //}

                var importerInfo = GetLoggedOnUserInfo();
                if (importerInfo.Id < 1)
                {
                    gVal.Error = "Your session has timed out";
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var validationResult = ValidateProcess(process);

                if (validationResult.Code == 1)
                {
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                var appStatus = new ProcessServices().AddProcess(process);
                if (appStatus < 1)
                {
                    validationResult.Code  = -1;
                    validationResult.Error = appStatus == -2 ? "Process upload failed. Please try again." : "The Process Information already exists";
                    return(Json(validationResult, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = appStatus;
                gVal.Error = "Process was successfully added.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                gVal.Error = "Process processing failed. Please try again later";
                gVal.Code  = -1;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 7
0
        public CoreServices(IApplicationConstants appConstants
                            , ITelemetryService telemetry
                            , ITaskService tasks
                            , IMainThread mainThread
                            , ISecurityService security)
        {
            Registry           = new RegistryImpl();
            LoggingPermissions = new LoggingPermissions(appConstants, telemetry, Registry);
            Telemetry          = telemetry;
            Security           = security;
            Tasks = tasks;

            ProcessServices = new ProcessServices();
            FileSystem      = new FileSystem();
            MainThread      = mainThread;

            Log = new Logger(appConstants.ApplicationName, Path.GetTempPath(), LoggingPermissions);
        }
        public void TestProcessCancel()
        {
            LogStart("TestProcessCancel");

            var source = new CancellationTokenSource();
            var task   = ProcessServices.RunProcess("pause.bat", "", source.Token);

            source.Cancel();

            try
            {
                task.Wait();
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Logger.Info($"Got (expected?) exception from process cancel: {ex}");
            }
        }
Esempio n. 9
0
        public ActionResult GetProcess(long id)
        {
            try
            {
                var Process = new ProcessServices().GetProcess(id);
                if (Process == null || Process.Id < 1)
                {
                    return(Json(new ProcessObject(), JsonRequestBehavior.AllowGet));
                }

                Session["_Process"] = Process;

                return(Json(Process, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new ProcessObject(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 10
0
        public static ICoreServices CreateReal()
        {
            var appConstants       = new TestAppConstants();
            var telemetryService   = new TelemetryTestService();
            var registry           = new RegistryImpl();
            var loggingPermissions = new LoggingPermissions(appConstants, telemetryService, registry);
            var log             = new Logger(new NullLogWriter(), loggingPermissions);
            var fileSystem      = new FileSystem();
            var processServices = new ProcessServices();

            return(new CoreServices(
                       telemetryService,
                       loggingPermissions,
                       new SecurityServiceStub(),
                       new TestTaskService(),
                       UIThreadHelper.Instance,
                       log,
                       fileSystem,
                       processServices));
        }
Esempio n. 11
0
        //private void BankName()
        //{
        //    cmbBank.Items.Add("PRODUCERS BANK");
        //    cmbBank.Items.Add("PNB");
        //    cmbBank.SelectedIndex = 0;
        //}

        private void GetData()
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;


            OpenFileDialog op = new OpenFileDialog();

            //op.InitialDirectory = Application.StartupPath;
            op.InitialDirectory = @"\\192.168.10.254\Accounting_Files\Packing";
            op.Filter           = "dbf files (*.dbf)|*.dbf|All files (*.*)|*.*";
            op.FilterIndex      = 2;
            op.RestoreDirectory = true;
            try
            {
                if (op.ShowDialog().Equals(DialogResult.OK))
                {
                    string          ConString = "Provider = VFPOLEDB.1; Data Source = " + op.FileName + ";";
                    OleDbConnection con       = new OleDbConnection(ConString);



                    //Get the path of specified file
                    filePath = Path.GetFileNameWithoutExtension(op.FileName);

                    //Read the contents of the file into a stream
                    var    fileStream = op.OpenFile();
                    string sql        = "";

                    if (gClient.DataBaseName == "producers_history")// Checking what table was selected to read the packing file
                    {
                        sql = "Select BATCHNO,RT_NO,BRANCH,ACCT_NO,CHKTYPE,ACCT_NAME1,ACCT_NAME2," +
                              "CK_NO_B,CK_NO_E FROM " + filePath;
                    }
                    else if (gClient.DataBaseName == "pnb_history")
                    {
                        sql = "Select BATCHNO,RT_NO,BRANCH,ACCT_NO,CHKTYPE,ACCT_NAME1,ACCT_NAME2," +
                              "CK_NO_B,CK_NO_E,BRANCHCODE,OLDBCODE FROM " + filePath;
                    }
                    OleDbCommand cmd = new OleDbCommand(sql, con);
                    con.Open();
                    OleDbDataReader myReader = cmd.ExecuteReader();

                    while (myReader.Read())
                    {
                        OrderModel order = new OrderModel();
                        order.Batch      = !myReader.IsDBNull(0) ? myReader.GetString(0) : "";
                        order.BRSTN      = !myReader.IsDBNull(1) ? myReader.GetString(1) : "";
                        order.BranchName = !myReader.IsDBNull(2) ? myReader.GetString(2) : "";
                        order.AccountNo  = !myReader.IsDBNull(3) ? myReader.GetString(3) : "";
                        order.ChkType    = !myReader.IsDBNull(4) ? myReader.GetString(4) : "";
                        order.Name1      = !myReader.IsDBNull(5) ? myReader.GetString(5) : "";
                        order.Name2      = !myReader.IsDBNull(6) ? myReader.GetString(6) : "";

                        order.StartingSerial = !myReader.IsDBNull(7) ? myReader.GetString(7) : "";
                        order.EndingSerial   = !myReader.IsDBNull(8) ? myReader.GetString(8) : "";
                        //PNB Required fields
                        if (gClient.DataBaseName == "pnb_history") // Additional  field if the  Bank is PNB
                        {
                            order.BranchCode    = !myReader.IsDBNull(9) ? myReader.GetString(9) : "";
                            order.OldBranchCode = !myReader.IsDBNull(10) ? myReader.GetString(10) : "";
                            proc.GetBranchLocation(branch, order.BranchCode); // Getting the Flag from bRanch Table
                            if (branch.Flag == 0)
                            {
                                order.Location = "Direct";
                            }
                            else
                            {
                                order.Location = "Provincial";
                            }
                        }

                        if (order.ChkType == "A" && comboBox1.Text == "Regular Checks")
                        {
                            order.ChequeName = "Regular Personal Checks";
                        }
                        else if (order.ChkType == "B" && comboBox1.Text == "Regular Checks")
                        {
                            order.ChequeName = "Regular Commercial Checks";
                        }
                        else
                        {
                            errorMessage += "\r\nCheque Type " + order.ChkType + " on batch : " + order.BRSTN.Trim() + ": " + order.BranchName.Trim() + " does not match\r\n";
                        }
                        if (order.ChkType == "A" && comboBox1.Text == "Manager's Checks")
                        {
                            order.ChequeName = "Manager's Checks";
                        }


                        orderList.Add(order);
                    }
                }
                else
                {
                    errorMessage += "The file :" + op.FileName + " is not a dbf file!\r\n";
                    Application.Exit();
                }
                var totalB = orderList.Where(a => a.ChkType == "B").ToList();
                var totalA = orderList.Where(a => a.ChkType == "A").ToList();
                // BindingSource checkBind = new BindingSource();
                // checkBind.DataSource = orderList;
                //     proc.CheckBatchifExisted(orderList[0].Batch.Trim());


                if (proc.CheckBatchifExisted(orderList[0].Batch.Trim()) == true)
                {
                    errorMessage += "\r\nBatch : " + orderList[0].Batch + " Is Already Existed!!";
                    MessageBox.Show(errorMessage);
                }


                //                }
                if (errorMessage != "")
                {
                    ProcessServices.ErrorMessage(errorMessage);
                    MessageBox.Show("Checking files done! with errors found! Check ErrorMessage.txt for references", "Error!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Checking files done! No Errors found");
                    dataGridView1.DataSource = orderList;
                    lblTotalA.Text           = totalA.Count.ToString();
                    lblTotalB.Text           = totalB.Count.ToString();
                    lblTotalChecks.Text      = orderList.Count.ToString();
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, error.StackTrace);
            }
        }