Beispiel #1
0
        public async Task <IList <Employee> > GetEmployees()
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                schema.EmployeeInfo.ServiceCommands.EveryEmployeeID,
                schema.EmployeeInfo.EmployeeID,
                schema.GeneralInfoContactInfo.FirstName,
                schema.GeneralInfoContactInfo.LastName
            },
                                                  new Filter[] { new Filter {
                                                                     Field = schema.EmployeeInfo.Status, Condition = FilterCondition.Equals, Value = "Active"
                                                                 } },
                                                  0, false, true);

            IList <Employee> list = new List <Employee>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new Employee(result.ExportResult[i][0].Trim(), result.ExportResult[i][1] + " " + result.ExportResult[i][2]));
            }
            return(list);
        }
        public async Task <IList <ExpenseItem> > GetExpenseItems()
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                schema.NonStockItemSummary.ServiceCommands.EveryInventoryID,
                schema.NonStockItemSummary.InventoryID,
                schema.NonStockItemSummary.Description
            },
                                                  new Filter[] { new Filter {
                                                                     Field = schema.GeneralSettingsItemDefaults.Type, Condition = FilterCondition.Equals, Value = "Expense", Operator = FilterOperator.And
                                                                 },
                                                                 /*TODO: not working as it should new Filter { Field = schema.NonStockItemSummary.ItemStatus, Condition = FilterCondition.Equals, Value = "Active", Operator = FilterOperator.And }*/ },
                                                  0, false, true);

            IList <ExpenseItem> list = new List <ExpenseItem>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new ExpenseItem(result.ExportResult[i][0].Trim(), result.ExportResult[i][1]));
            }
            return(list);
        }
        public async Task <string> GetExpenseItemDescription(string inventoryID)
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                new Value {
                    Value = inventoryID, LinkedCommand = schema.NonStockItemSummary.InventoryID
                },
                schema.NonStockItemSummary.Description
            },
                                                  null,
                                                  0, false, true);

            if (result.ExportResult.Length == 0)
            {
                return(String.Empty);
            }
            else
            {
                return(result.ExportResult[0][0]);
            }
        }
        private async Task <IList <ExpenseClaimBase> > GetExpenseClaimsList(Filter[] filter)
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                schema.DocumentSummary.Description,
                schema.DocumentSummary.ClaimedBy,
                schema.DocumentSummary.ReferenceNbr,
                schema.DocumentSummary.ClaimTotal,
                schema.DocumentSummary.Date,
                schema.DocumentSummary.Status
            },
                                                  filter,
                                                  0, false, true);

            var list = new List <ExpenseClaimBase>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new ExpenseClaimBase(
                             result.ExportResult[i][0],
                             result.ExportResult[i][1].Trim(),
                             result.ExportResult[i][2],
                             decimal.Parse(result.ExportResult[i][3], System.Globalization.CultureInfo.InvariantCulture),
                             DateTime.Parse(result.ExportResult[i][4], System.Globalization.CultureInfo.InvariantCulture),
                             result.ExportResult[i][5].Trim()));
            }
            return(list);
        }
        public async Task <IList <CustomerLocation> > GetCustomerLocations(string customerID)
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                new Value {
                    Value = customerID, LinkedCommand = schema.CustomerSummary.CustomerID
                },
                schema.Locations.LocationID,
                schema.Locations.LocationName,
            },
                                                  new Filter[] { new Filter {
                                                                     Field = schema.Locations.Active, Condition = FilterCondition.Equals, Value = "True"
                                                                 } },
                                                  0, false, true);

            IList <CustomerLocation> list = new List <CustomerLocation>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new CustomerLocation(result.ExportResult[i][0].Trim(), result.ExportResult[i][1]));
            }
            return(list);
        }
        public async Task <IList <Customer> > GetCustomers()
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                schema.CustomerSummary.ServiceCommands.EveryCustomerID,
                schema.CustomerSummary.CustomerID,
                schema.CustomerSummary.CustomerName,
            },
                                                  new Filter[] { new Filter {
                                                                     Field = schema.CustomerSummary.Status, Condition = FilterCondition.Equals, Value = "Active"
                                                                 } },
                                                  0, false, true);

            IList <Customer> list = new List <Customer>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new Customer(result.ExportResult[i][0].Trim(), result.ExportResult[i][1]));
            }
            return(list);
        }
        public async Task <IList <ProjectTask> > GetProjectTasks(string projectID)
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                new Value {
                    Value = projectID, LinkedCommand = schema.ProjectSummary.ProjectID
                },
                schema.Tasks.TaskID,
                schema.Tasks.Description
            },
                                                  new Filter[] { new Filter {
                                                                     Field = schema.Tasks.Status, Condition = FilterCondition.Equals, Value = "Active"
                                                                 } },
                                                  0, false, true);

            IList <ProjectTask> list = new List <ProjectTask>();

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                list.Add(new ProjectTask(result.ExportResult[i][0].Trim(), result.ExportResult[i][1]));
            }
            return(list);
        }
        public async Task <ExpenseClaim> GetExpenseClaim(string refNbr)
        {
            ScreenSoapClient client = await GetAuthenticatedClient(Common.SettingsStore.SiteUrl, Common.SettingsStore.Username, Common.SettingsStore.Password);

            var schema = await GetSavedSchema();

            await client.SetSchemaAsync(schema);

            var result = await client.ExportAsync(new Command[] {
                new Value {
                    Value = refNbr, LinkedCommand = schema.DocumentSummary.ReferenceNbr
                },
                schema.DocumentSummary.Description,
                schema.DocumentSummary.ClaimedBy,
                schema.DocumentSummary.ClaimTotal,
                schema.DocumentSummary.Date,
                schema.DocumentSummary.Status,
                schema.DocumentSummary.ApprovalDate,
                schema.DocumentSummary.Hold,
                schema.DocumentSummary.Location,
                schema.DocumentSummary.NoteText,
                new Field()
                {
                    FieldName = "ClaimDetailID", ObjectName = "ExpenseClaimDetails"
                },
                schema.ExpenseClaimDetails.Date,
                schema.ExpenseClaimDetails.RefNbr,
                schema.ExpenseClaimDetails.ExpenseItem,
                schema.ExpenseClaimDetails.Quantity,
                schema.ExpenseClaimDetails.UnitCost,
                schema.ExpenseClaimDetails.TotalAmount,
                schema.ExpenseClaimDetails.EmployeePart,
                schema.ExpenseClaimDetails.Billable,
                schema.ExpenseClaimDetails.Customer,
                schema.ExpenseClaimDetails.Location,
                schema.ExpenseClaimDetails.ProjectContract,
                schema.ExpenseClaimDetails.ProjectTask,
                schema.ExpenseClaimDetails.Description,
                schema.ExpenseClaimDetails.NoteText,
            },
                                                  null,
                                                  0, false, true);

            if (result.ExportResult.Length == 0)
            {
                return(null);
            }

            var claim = new ExpenseClaim(result.ExportResult[0][0].Trim(),
                                         result.ExportResult[0][1].Trim(),
                                         refNbr,
                                         decimal.Parse(result.ExportResult[0][2].Trim(), System.Globalization.CultureInfo.InvariantCulture),
                                         DateTime.Parse(result.ExportResult[0][3].Trim(), System.Globalization.CultureInfo.InvariantCulture),
                                         result.ExportResult[0][4].Trim());

            if (!String.IsNullOrEmpty(result.ExportResult[0][5]))
            {
                claim.ApprovalDate = DateTime.Parse(result.ExportResult[0][5], System.Globalization.CultureInfo.InvariantCulture);
            }

            claim.Hold     = bool.Parse(result.ExportResult[0][6]);
            claim.Location = result.ExportResult[0][7];
            claim.NoteText = result.ExportResult[0][8];

            for (int i = 0; i < result.ExportResult.Length; i++)
            {
                var lineNbr = result.ExportResult[i][9];
                if (String.IsNullOrEmpty(lineNbr))
                {
                    continue;
                }

                var line = new ExpenseClaimLine();
                line.ParentRefNbr = refNbr;
                line.LineNbr      = int.Parse(lineNbr, System.Globalization.CultureInfo.InvariantCulture);
                line.Date         = DateTime.Parse(result.ExportResult[i][10], System.Globalization.CultureInfo.InvariantCulture);
                line.RefNbr       = result.ExportResult[i][11];
                line.ExpenseId    = result.ExportResult[i][12].Trim();
                line.Quantity     = decimal.Parse(result.ExportResult[i][13], System.Globalization.CultureInfo.InvariantCulture);
                line.UnitCost     = decimal.Parse(result.ExportResult[i][14], System.Globalization.CultureInfo.InvariantCulture);
                line.Total        = decimal.Parse(result.ExportResult[i][15], System.Globalization.CultureInfo.InvariantCulture);
                line.EmployeePart = decimal.Parse(result.ExportResult[i][16], System.Globalization.CultureInfo.InvariantCulture);
                line.Billable     = bool.Parse(result.ExportResult[i][17]);
                line.Customer     = result.ExportResult[i][18].Trim();
                line.Location     = result.ExportResult[i][19].Trim();
                line.Project      = result.ExportResult[i][20].Trim();
                line.ProjectTask  = result.ExportResult[i][21].Trim();
                line.Description  = result.ExportResult[i][22];
                line.NoteText     = result.ExportResult[i][23];
                claim.Lines.Add(line);
            }

            var claimStatus = await client.SubmitAsync(new Command[]
            {
                new Value {
                    Value = refNbr, LinkedCommand = schema.DocumentSummary.ReferenceNbr
                },
                schema.DocumentSummary.Description
            });

            if (claimStatus.Length > 0)
            {
                // The schema needs to be generated with schema mode == detailed for this to work
                claim.AllowEdit = !claimStatus[0].DocumentSummary.Description.Descriptor.IsDisabled;
            }

            foreach (var line in claim.Lines)
            {
                line.AllowEdit         = claim.AllowEdit;
                line.HasUnsavedChanges = false;
            }

            claim.HasUnsavedChanges = false;
            return(claim);
        }