// 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"
     };
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 5
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.º 6
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.º 7
0
 public static CssCommandResult ChangeAccountCode(CssAccountFile file, AccountList list, AccountCode newCode, Note changeNote, CssCredentials cssCredentials)
 {
     return(ChangeIt2(file, list, "", "", "", newCode.Code, changeNote, cssCredentials));
 }