예제 #1
0
        public static void SqlUpdate(int id, DateTime poDate, string poNum, string supplierCode, int projectId, bool billable)
        {
            string sql = $"update FieldPO set POdate='{poDate}', PONum='{StrEx.SqlEsc(poNum)}', SupplierCode='{supplierCode}', projectId={projectId}, " +
                         $"Billable='{billable}', FieldPOStatus='{(char)EnumSubmitStatus.Open}', SyncStatus='{EnumRecordSyncStatus.NoSubmit}' where Id={id}";

            MobileCommon.ExecuteNonQuery(sql);
        }
예제 #2
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive()
        {
            try
            {
                Company.Refresh();

                using (HttpClient client = new HttpClient())
                {
                    client.Init();

                    HttpResponseMessage response = await client.GetAsync("api/Companies");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Company> list = await response.Content.ReadAsAsync <List <Company> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Company(MatchId, CompanyName, ShortName, Active, WeekStart, " +
                                         $"EquipRateGroupType, MaxLevelCode, Level1CodeDesc, Level2CodeDesc, Level3CodeDesc, Level4CodeDesc, " +
                                         $"CompanyAddress1, CompanyAddress2, CompanyAddress3, CompanyCity, CompanyState, CompanyZip, CompanyPhone, CompanyFax, " +
                                         $"CompanyEmail, CompanyWeb, InSync) " +
                                         $"values({x.MatchId}, '{StrEx.SqlEsc(x.CompanyName)}', '{x.ShortName}', '{x.Active}', {(Int16)x.WeekStart}, " +
                                         $"'{(char)x.EquipRateGroupType}', {x.MaxLevelCode}, '{x.Level1CodeDesc}', '{x.Level2CodeDesc}', '{x.Level3CodeDesc}', '{x.Level4CodeDesc}', " +
                                         $"'{StrEx.SqlEsc(x.CompanyAddress1)}', '{StrEx.SqlEsc(x.CompanyAddress2)}', '{StrEx.SqlEsc(x.CompanyAddress3)}', '{x.CompanyCity}', '{x.CompanyState}', " +
                                         $"'{x.CompanyZip}', '{x.CompanyPhone}', '{x.CompanyFax}', '{x.CompanyEmail}', '{x.CompanyWeb}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #3
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Employee.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Employees?companyId={Company.CurrentId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Employee> list = await response.Content.ReadAsAsync <List <Employee> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Employee(EmpNum, CompanyId, FirstName, LastName, WorkClassCode, OvertimeCode, InSync) " +
                                         $"values({x.EmpNum}, {x.CompanyId}, '{StrEx.SqlEsc(x.FirstName)}', '{StrEx.SqlEsc(x.LastName)}', '{x.WorkClassCode}', '{x.OvertimeCode}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }

                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #4
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Equipment.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Equipments?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Equipment> list = await response.Content.ReadAsAsync <List <Equipment> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Equipment(EqpNum, CompanyId, AssetCode, [Desc], ClassCode, CategoryCode, OwnerType, InSync) " +
                                         $"values('{x.EqpNum}', {x.CompanyId}, '{StrEx.SqlEsc(x.AssetCode)}', '{StrEx.SqlEsc(x.Desc)}', '{StrEx.SqlEsc(x.ClassCode)}', '{StrEx.SqlEsc(x.CategoryCode)}', '{(char)x.OwnerType}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #5
0
        public static void SqlUpdate(int id, DateTime logDate, int projectId, EnumLogStatus status, string desc)
        {
            string sql = $"Update LemHeader set LogDate='{logDate}', ProjectId={projectId}, LogStatus='{(char)status}', SubmitStatus='{(char)EnumSubmitStatus.Open}', LEM_Desc='{StrEx.SqlEsc(desc)}' where id={id}";

            MobileCommon.ExecuteNonQuery(sql);
        }
예제 #6
0
        public static int SqlInsert(DateTime logDate, int projectId, string lemNum, string desc)
        {
            string sql = $"insert LemHeader(MatchId, CompanyId, LogDate, LogStatus, SubmitStatus, ProjectId, LemNum, LEM_Desc, CreatorId, Deleted) " +
                         $"values(-1, {Company.CurrentId}, '{logDate}', '{(char)EnumLogStatus.Pending}', '{(char)EnumSubmitStatus.Open}', {projectId}, '{lemNum}', '{StrEx.SqlEsc(desc)}', {LoginUser.CurrUser.MatchId}, 0); " +
                         $"Select CAST(SCOPE_IDENTITY() AS INT);";

            return(Convert.ToInt32(MobileCommon.ExecuteScalar(sql)));
        }
예제 #7
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Supplier.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Suppliers?companyId={Company.CurrentId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Supplier> list = await response.Content.ReadAsAsync <List <Supplier> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Supplier(CompanyId, SupplierCode, SupplierName, InSync) values({x.CompanyId}, '{StrEx.SqlEsc(x.SupplierCode)}', '{StrEx.SqlEsc(x.SupplierName)}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }

                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #8
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["contactId"] = LoginUser.CurrUser.MatchId.ToString();
                    query["companyId"] = CompanyId.ToString();
                    HttpResponseMessage response = await client.GetAsync($"api/CostCodeMapping?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <CostCodeMapping> list = await response.Content.ReadAsAsync <List <CostCodeMapping> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert CostCodeMapping(CompanyId, ProjectId, MappingId, MappingCode, InSync) " +
                                         $"values({x.CompanyId}, {x.ProjectId}, {x.MappingId}, '{StrEx.SqlEsc(x.MappingCode)}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #9
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    var query = HttpUtility.ParseQueryString(string.Empty);
                    query["companyId"] = CompanyId.ToString();
                    query["clientMac"] = MobileCommon.MachineMac;
                    query["contactId"] = LoginUser.CurrUser.MatchId.ToString();
                    HttpResponseMessage response = await client.GetAsync($"api/LemHeader?{query.ToString()}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        var list = await response.Content.ReadAsAsync <List <LemHeader> >();

                        list.ForEach(x =>
                        {
                            BeforeReceiveRecord(x.MatchId);

                            string sql = $"insert LemHeader(MatchId, CompanyId, LogDate, LogStatus, SubmitStatus, ProjectId, LemNum, LEM_Desc, ApprovalComments, CreatorId, SyncStatus, Deleted) " +
                                         $"values({x.MatchId}, {x.CompanyId}, '{x.LogDate}', '{(char)x.LogStatus}', '{(char)EnumSubmitStatus.Open}', {x.ProjectId}, '{x.LemNum}', '{StrEx.SqlEsc(x.Description)}', '{StrEx.SqlEsc(x.ApprovalComments)}', {x.CreatorId}, '{EnumRecordSyncStatus.Receiving}', 0);";

                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
예제 #10
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                Project.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/Projects?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <Project> list = await response.Content.ReadAsAsync <List <Project> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert Project(MatchId, CompanyId, Name, Code, CustomerId, CustomerCode, CustomerName, CustomerAddress, POReference, SiteLocation, StartDate, EstCompletionDate, " +
                                         $"SiteAddress, SiteCity, SiteState, SiteZip, CustomerAddress2, CustomerAddress3, CustomerCity, CustomerState, CustomerZip, ProjectExtendedDescription, Billable, InSync) " +
                                         $"values({x.MatchId}, {x.CompanyId}, '{x.Name}', {x.Code}, {x.CustomerId}, '{x.CustomerCode}', '{x.CustomerName}', '{x.CustomerAddress}', {StrEx.StrOrNull(x.POReference)}, '{x.SiteLocation}', {StrEx.StrOrNull(x.StartDate)}, {StrEx.StrOrNull(x.EstCompletionDate)}, " +
                                         $"'{x.SiteAddress}', '{x.SiteCity}', '{x.SiteState}', '{x.SiteZip}', '{x.CustomerAddress2}', '{x.CustomerAddress3}', '{x.CustomerCity}', '{x.CustomerState}', '{x.CustomerZip}', '{StrEx.SqlEsc(x.ProjectExtendedDescription)}', '{x.Billable}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }