public JsonResult GetContractsFileModel()
        {
            var filtrCriteria = new AccountFilterCriteria <Contracts> ();

            filtrCriteria.AddCriterion(new Criterion()
            {
                Attribute = "DEV.CODE", Filter = "6600"
            });
            filtrCriteria.AddCriterion(new Criterion()
            {
                Attribute = "PROJ.CODE", Filter = "6606"
            });
            filtrCriteria.AddCriterion(new Criterion()
            {
                Attribute = "LEND.CODE", Filter = "100"
            });
            filtrCriteria.AddCriterion(new Criterion()
            {
                Attribute = "AC", Filter = "N"
            });

            var credentials = new CssCredentials();
            var model       = new ContractsFilterCallModel()
            {
                Credentials = credentials, FilterCriteria = filtrCriteria
            };

            return(new JsonResult(model));
        }
 // ReSharper disable once UnusedMember.Global
 public ChangeItRequest(string changeType, AccountList getList, CssCredentials credentials, CssAccountFile file, Note note)
 {
     TypeOfChange = changeType;
     GetListName  = getList;
     Credentials  = credentials;
     File         = file;
     Note         = note;
 }
 public CssCallModel(CssAccountFile file)
 {
     File        = file;
     Credentials = new CssCredentials();
     CssDataFile = new AccountList()
     {
         AccountListName = "empty"
     };
 }
        private static CssCommandResult MakeMultiNote(AccountList list, Note note, CssCredentials cssCredentials)
        {
            var result = new CssCommandResult();

            var          lHostName    = _cssHostname ?? cssCredentials.Hostname;
            var          lAccount     = _cssAccount ?? cssCredentials.Account;
            var          lUser        = _cssUserName ?? cssCredentials.User;
            var          lPassword    = _cssUserPassword ?? cssCredentials.UserPassword;
            const string lServiceType = CssServiceType;

            UniSession us = null;

            try
            {
                Console.WriteLine($"{lHostName}, {lUser}, {lAccount}, {lServiceType}");

                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                UniCommand cmd = us.CreateUniCommand();
                cmd.Command = $"GET-LIST {list.AccountListName}";
                cmd.Execute();

                cmd.Command = "MULTI.NOTES";
                cmd.Execute();

                cmd.Reply($"{note.Message}");

                cmd.Reply("AGHERRERA");

                cmd.Reply("G");

                int lineNumber = 0;
                foreach (var line in cmd.Response.Split("\r\n"))
                {
                    result.Results.Add(new CommandResponse($"Response Line: {++lineNumber}", line));
                }

                return(result);
            }
            catch (Exception ex)
            {
                result.Results.Add(new CommandResponse("Exception", ex.ToString()));
            }
            finally
            {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }

            result.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return(result);
        }
        private static CssCommandResult Filter(string indexFile, string developerCode, string filterCriteria,
            AccountList saveListName, CssCredentials cssCredentials)
        {
            var result = new CssCommandResult();
            var lHostName = _cssHostname ?? cssCredentials.Hostname;
            var lAccount = _cssAccount ?? cssCredentials.Account;
            var lUser = _cssUserName ?? cssCredentials.User;
            var lPassword = _cssUserPassword ?? cssCredentials.UserPassword;
            const string lServiceType = CssServiceType;

            UniSession us = null;

            try
            {
                Console.WriteLine($"{lHostName}, {lUser}, {lAccount}, {lServiceType}");

                //get the session object
                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                UniCommand cmd = us.CreateUniCommand();
                cmd.Command = $"SELECT {indexFile} WITH DEV.CODE = \"{developerCode}\"";
                cmd.Execute();
                result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                cmd.Command = $"QSELECT {indexFile}";
                cmd.Execute();
                result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                cmd.Command = filterCriteria;
                cmd.Execute();
                result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                cmd.Command = $"SAVE-LIST {saveListName}";
                cmd.Execute();
                result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                return result;

            }
            catch (Exception ex)
            {
                result.Results.Add(new CommandResponse("Exception", ex.ToString()));
            }
            finally
            {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }

            result.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return result;
        }
        public ActionResult <MaintFilterCallModel> GetMaintFileModel()
        {
            var filtrCriteria = new AccountFilterCriteria <Maint>();

            filtrCriteria.AddCriterion(new Criterion()
            {
                Attribute = "DEV.CODE", Filter = "1075"
            });
            var credentials = new CssCredentials();
            var model       = new MaintFilterCallModel()
            {
                Credentials = credentials, FilterCriteria = filtrCriteria
            };

            return(model);
        }
 public static CssCommandResult MakeCustomGetList(IEnumerable<string> list, 
     AccountList saveList, 
     CssCredentials cssCredentials)
 {
     return CustomGetList(list, saveList, cssCredentials);
 }
 public static CssCommandResult FilterContracts(AccountFilterCriteria<Contracts> contractsFilter, AccountList saveList,
     CssCredentials cssCredentials)
 {
     return Filter("ACTIVE.IDX", contractsFilter.DeveloperCode, contractsFilter.ToString(), saveList, cssCredentials);
 }
 public static CssCommandResult FilterMaint(AccountFilterCriteria<Maint> mainFilter, AccountList saveList,
         CssCredentials cssCredentials)
 {
     return Filter("MACTIVE.IDX", mainFilter.DeveloperCode, mainFilter.ToString(), saveList, cssCredentials);
 }
        private static CssCommandResult CustomGetList(IEnumerable<string> accountList, AccountList saveListName, CssCredentials cssCredentials)
        {
            var result = new CssCommandResult();
            var lHostName = _cssHostname ?? cssCredentials.Hostname;
            var lAccount = _cssAccount ?? cssCredentials.Account;
            var lUser = _cssUserName ?? cssCredentials.User;
            var lPassword = _cssUserPassword ?? cssCredentials.UserPassword;
            const string lServiceType = CssServiceType;

            UniSession us = null;

            try
            {
                Console.WriteLine($"{lHostName}, {lUser}, {lAccount}, {lServiceType}");
                //get the session object
                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                UniCommand cmd = us.CreateUniCommand();
                cmd.Command = $"EDIT-LIST {saveListName.AccountListName}";
                cmd.Execute();
                result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                cmd.Reply("I"); //Get list ready for insert

                foreach (var acct in accountList)
                {
                    if (!acct.Contains("=")) continue;
                    var account = acct.Split("=")[1].Replace("]","");
                    cmd.Reply($"{account}");
                }
                cmd.Reply(""); // Send empty marker to close list

                cmd.Reply("FI"); // Save list
                result.Results.Add(new CommandResponse(cmd.CommandStatus.ToString(), cmd.Response));

                return result;

            }
            catch (Exception ex)
            {
                result.Results.Add(new CommandResponse("Exception", ex.ToString()));
            }
            finally
            {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }

            result.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return result;
        }
Exemplo n.º 11
0
 public CustomGetList()
 {
     Credentials = new CssCredentials();
     Accounts    = new List <string>();
 }
Exemplo n.º 12
0
 public static CssCommandResult ChangeAccountCode(CssAccountFile file, AccountList list, AccountCode newCode, Note changeNote, CssCredentials cssCredentials)
 {
     return(ChangeIt2(file, list, "", "", "", newCode.Code, changeNote, cssCredentials));
 }
Exemplo n.º 13
0
 public MaintFilterCallModel()
 {
     Credentials    = new CssCredentials();
     FilterCriteria = new AccountFilterCriteria <Maint>();
 }
 public MultiNoteModel()
 {
     GetList     = new AccountList();
     Credentials = new CssCredentials();
     Note        = new Note("This is the note");
 }
 public static CssCommandResult MakeNote(AccountList list, Note note, CssCredentials cssCredentials)
 {
     return(MakeMultiNote(list, note, cssCredentials));
 }
Exemplo n.º 16
0
 public ContractsFilterCallModel()
 {
     Credentials    = new CssCredentials();
     FilterCriteria = new AccountFilterCriteria <Contracts>();
 }
Exemplo n.º 17
0
        private static CssCommandResult ChangeIt2(CssAccountFile file, AccountList list, string developerCode, string projectCode, string lenderCode, string accountCode, Note changeNote, CssCredentials cssCredentials)
        {
            var result = new CssCommandResult();

            var          lHostName    = _cssHostname ?? cssCredentials.Hostname;
            var          lAccount     = _cssAccount ?? cssCredentials.Account;
            var          lUser        = _cssUserName ?? cssCredentials.User;
            var          lPassword    = _cssUserPassword ?? cssCredentials.UserPassword;
            const string lServiceType = CssServiceType;

            string     fileInitial = file.FileName.ToCharArray() [0].ToString();
            UniSession us          = null;

            try {
                Console.WriteLine($"{lHostName}, {lUser}, {lAccount}, {lServiceType}");

                //get the session object
                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                UniCommand cmd = us.CreateUniCommand();
                cmd.Command = "CHANGE.IT2";
                cmd.Execute();
                //result.Results.Add(new CommandResponse(cmd.Command, cmd.Response));

                //ENTER THE LIST NAME YOU ARE USING
                cmd.Reply($"{list.AccountListName}");
                //result.Results.Add(new CommandResponse("", cmd.Response));

                //'C'ONTRACT OR 'M'AINTENANCE IDS? ?
                cmd.Reply($"{fileInitial}");
                //result.Results.Add(new CommandResponse($"{fileInitial}", cmd.Response));

                //CHANGE MAINTENANCE TOO? (IF APPLICABLE) ?
                cmd.Reply("N");
                //result.Results.Add(new CommandResponse("N", cmd.Response));

                //ENTER NEW DEVELOPER CODE, IF ANY ?
                if (!string.IsNullOrEmpty(developerCode))
                {
                    cmd.Reply($"{developerCode}");
                    //result.Results.Add(new CommandResponse($"{developerCode}", cmd.Response));

                    //WARNING: Dev Code changes may cause conflict with legal agreements.\r\n
                    //Is our legal department aware of new dev/len relationships? (Y/N)
                    cmd.Reply("Y");
                    //result.Results.Add(new CommandResponse("Legal Department", cmd.Response));
                }
                else
                {
                    cmd.Reply($"{developerCode}");
                    //result.Results.Add(new CommandResponse($"{projectCode}", cmd.Response));
                }

                //Project?
                cmd.Reply($"{projectCode}");
                //result.Results.Add(new CommandResponse($"{projectCode}", cmd.Response));

                //Lender
                cmd.Reply($"{lenderCode}");
                //result.Results.Add(new CommandResponse($"{lenderCode}", cmd.Response));

                //AccountCode
                cmd.Reply($"{accountCode}");
                //result.Results.Add(new CommandResponse($"{accountCode}", cmd.Response));

                //Note
                cmd.Reply($"{changeNote.Message}");
                //result.Results.Add(new CommandResponse($"{changeNote.Message}", cmd.Response));

                //Note Type
                cmd.Reply("G");
                //result.Results.Add(new CommandResponse($"NoteType", cmd.Response));

                if (cmd.Response.Contains("OKAY TO PROCEED? (Y/N)"))
                {
                    //OKAY TO PROCEED? (Y/N)
                    cmd.Reply("Y");
                }
                else
                {
                    throw new Exception($"Could not get confirmation message. Raw result: {cmd.Response}");
                }

                int lineNumber = 0;
                foreach (var line in cmd.Response.Split("\r\n"))
                {
                    result.Results.Add(new CommandResponse($"Response Line: {++lineNumber}", line));
                }

                return(result);
            } catch (Exception ex) {
                result.Results.Add(new CommandResponse("Exception", ex.ToString()));
            } finally {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }

            result.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return(result);
        }
Exemplo n.º 18
0
 public static CssCommandResult ChangeDplCode(CssAccountFile file, AccountList list, DplCode newCode, Note changeNote, CssCredentials cssCredentials)
 {
     return(ChangeIt2(file, list, newCode.GetDeveloperCode(), newCode.GetProjectCode(), newCode.GetLenderCode(), "", changeNote, cssCredentials));
 }
Exemplo n.º 19
0
        public static CssFileResult GetData(AccountList list, CssAccountFile file, CssCredentials cssCredentials)
        {
            var lHostName    = cssCredentials.Hostname;
            var lAccount     = cssCredentials.Account;
            var lUser        = cssCredentials.User;
            var lPassword    = cssCredentials.UserPassword;
            var lServiceType = cssCredentials.ServiceType;

            var response    = new CssFileResult();
            var fileResults = new CssFile {
                FileName = list.AccountListName
            };

            UniSession us = null;

            try
            {
                //get the session object
                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                // create select list
                UniSelectList selectList = us.CreateUniSelectList(2);
                selectList.GetList(list.AccountListName);

                // read records using array of records ids
                var ids = selectList.ReadListAsStringArray();

                //open file
                UniFile cssFile = us.CreateUniFile(file.FileName);
                var     lSet    = cssFile.ReadRecords(ids);

                //var dict = us.CreateUniDictionary(file.FileName);
                //var field1 = dict.ReadField(1);

                //use foreach statement to construct data to be displayed
                foreach (UniRecord item in lSet)
                {
                    var record    = new CssRecord(item.RecordID, "");
                    var numFields = item.Record.Dcount();
                    for (int i = 0; i < numFields; i++)
                    {
                        var field = item.Record.Extract(i);

                        var valuesCount = field.Dcount();
                        if (valuesCount > 1)
                        {
                            throw new Exception("This field has sub-values" + field);
                        }
                        record.Fields.Add(new CssField(i.ToString(), field.ToString()));
                    }
                    fileResults.Records.Add(record);
                }

                response.FileContents = fileResults;

                return(response);
            }
            catch (Exception ex)
            {
                response.CssResponses.Results.Add(new CommandResponse("Exception", ex.ToString()));
            }
            finally
            {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }
            response.CssResponses.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return(response);
        }
 public CssCallModel(CssCredentials credentials, AccountList accountList, CssAccountFile file)
 {
     Credentials = credentials;
     CssDataFile = accountList;
     File        = file;
 }