示例#1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <string, string>("MyApp", "FieldsListUpdated", (sender, arg) =>
            {
                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <UserModelDB>();

                if (App.UserListDb.Count == 0)
                {
                    var json_salespersons   = Newtonsoft.Json.JsonConvert.SerializeObject(App.salespersons);
                    var json_customers_list = Newtonsoft.Json.JsonConvert.SerializeObject(App.cusList);
                    var jso_products_list   = Newtonsoft.Json.JsonConvert.SerializeObject(App.productList);
                    var jso_warehoue_list   = Newtonsoft.Json.JsonConvert.SerializeObject(App.warehousList);
                    var jso_journal_list    = Newtonsoft.Json.JsonConvert.SerializeObject(App.journalList);
                    var jso_tax_list        = Newtonsoft.Json.JsonConvert.SerializeObject(App.taxList);

                    var sample = new UserModelDB
                    {
                        userid            = App.userid,
                        partnerid         = App.partner_id,
                        user_image_medium = App.partner_image,
                        user_email        = App.partner_email,
                        user_name         = App.partner_name,
                        sales_persons     = json_salespersons,
                        customers_list    = json_customers_list,
                        products          = jso_products_list,
                        warehouse_list    = jso_warehoue_list,
                        journal_list      = jso_journal_list,
                        tax_list          = jso_tax_list
                    };
                    App._connection.Insert(sample);
                }
            });

            MessagingCenter.Subscribe <string, string>("MyApp", "Login", async(sender, arg) =>
            {
                await Task.Run(() =>
                {
                    var user_details = (from y in App._connection.Table <UserModelDB>() select y).ToList();
                    if (App.cusList.Count == 0 && user_details.Count == 0 && Settings.UserId != 0)
                    {
                        App.cusList           = Controller.InstanceCreation().GetCustomersList();
                        JObject sales_persons = Controller.InstanceCreation().GetSalespersonsList();
                        App.salespersons      = sales_persons.ToObject <Dictionary <int, string> >();
                        App.journalList       = Controller.InstanceCreation().GetjournalList();
                        App.taxList           = Controller.InstanceCreation().GettaxList();
                        App.warehousList      = Controller.InstanceCreation().GetwarehouseList();
                        App.productList       = Controller.InstanceCreation().GetProductssList();
                        MessagingCenter.Send <string, string>("MyApp", "FieldsListUpdated", "true");
                    }
                });
            });
        }
示例#2
0
        protected override void OnAppearing()
        {
            base.OnAppearing();



            MessagingCenter.Subscribe <string, string>("MyApp", "referesh", (sender, arg) =>
            {
                // List<CRMLead> crmLeadData = Controller.InstanceCreation().crmLeadData();
                crmLeadListView.ItemsSource = App.crmList;
            });



            MessagingCenter.Subscribe <string, string>("MyApp", "FieldsListUpdated", (sender, arg) =>
            {
                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <UserModelDB>();

                if (App.UserListDb.Count == 0)
                {
                    //var json_salespersons = Newtonsoft.Json.JsonConvert.SerializeObject(App.salespersons);
                    //var json_customers_list = Newtonsoft.Json.JsonConvert.SerializeObject(App.cusList);
                    //var jso_products_list = Newtonsoft.Json.JsonConvert.SerializeObject(App.productList);
                    //var jso_warehoue_list = Newtonsoft.Json.JsonConvert.SerializeObject(App.warehousList);
                    //var jso_tax_list = Newtonsoft.Json.JsonConvert.SerializeObject(App.taxList);

                    var sample = new UserModelDB
                    {
                        userid            = App.userid,
                        partnerid         = App.partner_id,
                        user_image_medium = App.partner_image,
                        user_email        = App.partner_email,
                        user_name         = App.partner_name,
                        //sales_persons = json_salespersons,
                        //customers_list = json_customers_list,
                        //products = jso_products_list,
                        //warehouse_list = jso_warehoue_list,
                        //tax_list = jso_tax_list
                    };
                    App._connection.Insert(sample);
                }
            });
        }
示例#3
0
        public List <CRMLead> crmLeadData()
        {
            String[] colourcodes = new String[] { "#3498db", "#e67e22", "#c0392b", "#2ecc71", "#d35400", "#27ae60", " #e74c3c", "#2980b9" };
            try
            {
                //JObject res = odooConnector.odooCrmLeadDataCall("sale.crm", "get_your_pipelines_all_orders");

                App.filterdict["range"] = "False";
                App.filterdict["days"]  = "False";
                App.filterdict["month"] = "True";

                //   odooConnector = OdooRPC.InstanceCreation(Settings.UserUrlName);
                JObject res = odooConnector.odooFilterDataCall("sale.crm", "get_your_pipelines_all_orders");

                //List<OrderLine> test = new List<OrderLine>();

                App.statedict   = res["state_list"].ToObject <Dictionary <int, string> >();
                App.countrydict = res["country_list"].ToObject <Dictionary <int, string> >();

                App.partner_name  = res["user_name"].ToString();
                App.partner_image = res["user_image_medium"].ToString();
                App.partner_id    = res["partner_id"].ToObject <int>();
                App.partner_email = res["user_email"].ToString();

                App.taxList     = res["taxes"].ToObject <List <taxes> >();
                App.paytermList = res["payment_terms"].ToObject <List <paytermList> >();

                App.commisiongroupList = res["commission_group"].ToObject <List <commisiongroupList> >();

                App.salesteam    = res["sales_team"].ToObject <Dictionary <int, string> >();
                App.salespersons = res["sales_persons"].ToObject <Dictionary <int, string> >();

                App.productList = res["Products"].ToObject <List <ProductsList> >();

                App.user_location_string = res["location"].ToString();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <UserModelDB>();


                if (App.UserListDb.Count == 0)
                {
                    var json_state = Newtonsoft.Json.JsonConvert.SerializeObject(res["state_list"]);

                    var json_country = Newtonsoft.Json.JsonConvert.SerializeObject(res["country_list"]);

                    var json_tags         = Newtonsoft.Json.JsonConvert.SerializeObject(res["crm_lead_tags"]);
                    var json_salesteam    = Newtonsoft.Json.JsonConvert.SerializeObject(res["sales_team"]);
                    var json_salespersons = Newtonsoft.Json.JsonConvert.SerializeObject(res["sales_persons"]);

                    var json_customers_list = Newtonsoft.Json.JsonConvert.SerializeObject(res["Customers"]);
                    var json_next_activity  = Newtonsoft.Json.JsonConvert.SerializeObject(res["next_activity"]);
                    var json_stages         = Newtonsoft.Json.JsonConvert.SerializeObject(res["stages"]);

                    var json_payment_terms = Newtonsoft.Json.JsonConvert.SerializeObject(res["payment_terms"]);

                    var json_commission_groups = Newtonsoft.Json.JsonConvert.SerializeObject(res["commission_group"]);

                    var jso_tags_list = Newtonsoft.Json.JsonConvert.SerializeObject(res["taxes"]);

                    var jso_products_list = Newtonsoft.Json.JsonConvert.SerializeObject(res["Products"]);


                    var sample = new UserModelDB
                    {
                        userid            = App.userid,
                        partnerid         = App.partner_id,
                        user_image_medium = App.partner_image,
                        user_email        = App.partner_email,
                        user_name         = App.partner_name,
                        state_list        = json_state,
                        country_list      = json_country,
                        tagsPicker        = json_tags,
                        sales_team        = json_salesteam,
                        sales_persons     = json_salespersons,
                        customers_list    = json_customers_list,
                        next_activity     = json_next_activity,
                        stages            = json_stages,
                        payment_terms     = json_payment_terms,
                        commission_group  = json_commission_groups,
                        tax_list          = jso_tags_list,
                        products          = jso_products_list
                    };
                    App._connection.Insert(sample);

                    try
                    {
                        var details = (from y in App._connection.Table <UserModelDB>() select y).ToList();

                        App.UserListDb = details;

                        List <ProductsList>      productslistdb = new List <ProductsList>();
                        Dictionary <int, string> cusdictdb      = new Dictionary <int, string>();
                        foreach (var item in App.UserListDb)
                        {
                            productslistdb = JsonConvert.DeserializeObject <List <ProductsList> >(item.products);

                            cusdictdb = JsonConvert.DeserializeObject <Dictionary <int, string> >(item.customers_list);

                            App.ProductListDb = productslistdb;
                            App.cusdictDb     = cusdictdb;
                            App.userid_db     = item.userid;
                        }
                    }


                    catch
                    {
                        int te = 0;
                    }

                    //List<ProductsList> productslistdb = new List<ProductsList>();
                    //foreach (var item in App.UserListDb)
                    //{
                    //    productslistdb = JsonConvert.DeserializeObject<List<ProductsList>>(item.products);

                    //    App.productList = productslistdb;
                    //}
                }



                App.nextActivityList = res["next_activity"].ToObject <List <next_activity> >();

                App.crmList = res["crm_leads"].ToObject <List <CRMLead> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <CRMLeadDB>();

                var crmlead_details = App._connection.Query <CRMLeadDB>("SELECT * from CRMLeadDB where yellowimg_string = ?", "yellowcircle.png");

                if (crmlead_details.Count() == 0)
                {
                    App._connection.Query <SalesQuotationDB>("DELETE from CRMLeadDB");

                    foreach (var item in App.crmList)
                    {
                        var sample = new CRMLeadDB
                        {
                            id               = item.id,
                            customer         = item.customer,
                            next_activity    = item.next_activity,
                            name             = item.name,
                            probability      = item.probability,
                            phone            = item.phone,
                            title_action     = item.title_action,
                            expected_revenue = item.expected_revenue,

                            team_name    = item.team_name,
                            priority     = item.priority,
                            state        = item.state,
                            street       = item.street,
                            street2      = item.street2,
                            city         = item.city,
                            country      = item.country,
                            contact_name = item.contact_name,
                            mobile       = item.mobile,
                            email        = item.email,
                            pipe_date    = item.pipe_date,
                            pipe_date1   = item.pipe_date1,
                            conDate      = item.conDate,
                            conDate1     = item.conDate1,
                            DateOrder    = item.DateOrder,
                            FullState    = item.FullState,

                            state_colour = item.state_colour,

                            //order_line = item.order_line[0].ToString()
                        };
                        App._connection.Insert(sample);


                        //App._samp.Add(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <CRMLeadDB>() select y).ToList();

                        App.crmListDb = details;
                    }

                    catch
                    {
                        int te = 0;
                    }
                }

                App.crmOpprList = res["crm_quotations"].ToObject <List <CRMOpportunities> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <CRMOpportunitiesDB>();

                var crmoppo_details = App._connection.Query <CRMOpportunitiesDB>("SELECT * from CRMOpportunitiesDB where yellowimg_string = ?", "yellowcircle.png");

                if (crmoppo_details.Count == 0)
                {
                    App._connection.Query <SalesQuotationDB>("DELETE from CRMOpportunitiesDB");
                    foreach (var item in App.crmOpprList)
                    {
                        var sample = new CRMOpportunitiesDB
                        {
                            customer         = item.customer,
                            next_activity    = item.next_activity,
                            name             = item.name,
                            probability      = item.probability,
                            phone            = item.phone,
                            title_action     = item.title_action,
                            expected_revenue = item.expected_revenue,
                            team_name        = item.team_name,
                            priority         = item.priority,
                            state            = item.state,
                            street           = item.street,
                            street2          = item.street2,
                            city             = item.city,
                            country          = item.country,
                            contact_name     = item.contact_name,
                            mobile           = item.mobile,
                            email            = item.email,
                            FullState        = item.FullState,
                            state_colour     = item.state_colour,
                            pipe_date        = item.pipe_date,
                            //pipe_datetime = item.pipe_datetime,
                            //pipe_datetime1 = item.pipe_datetime1,
                            pipe_datetime  = item.pipe_datetime.ToString(),
                            pipe_datetime1 = item.pipe_datetime1.ToString(),
                            DateOrder      = item.DateOrder,
                            newpipe_date   = item.newpipe_date,
                        };
                        App._connection.Insert(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <CRMOpportunitiesDB>() select y).ToList();

                        App.CRMOpportunitiesListDb = details;
                    }
                    catch
                    {
                        int te = 0;
                    }
                }

                App.salesQuotList = res["sale_quotations"].ToObject <List <SalesQuotation> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <SalesQuotationDB>();

                var sq_details = App._connection.Query <SalesQuotationDB>("SELECT * from SalesQuotationDB where yellowimg_string = ?", "yellowcircle.png");


                if (sq_details.Count() == 0)
                {
                    App._connection.Query <SalesQuotationDB>("DELETE from SalesQuotationDB");

                    foreach (var item in App.salesQuotList)
                    {
                        var json_orderline = Newtonsoft.Json.JsonConvert.SerializeObject(item.order_line);
                        var sample         = new SalesQuotationDB
                        {
                            customer = item.customer,
                            //    next_activity = item.next_activity,
                            name = item.name,
                            //  probability = item.probability,
                            // phone = item.phone,
                            //  title_action = item.title_action,
                            //  expected_revenue = item.expected_revenue,
                            payment_term = item.payment_term,
                            // team_name = item.team_name,
                            priority = item.priority,
                            state    = item.state,
                            street   = item.street,
                            street2  = item.street2,
                            city     = item.city,
                            country  = item.country,
                            // contact_name = item.contact_name,
                            //  mobile = item.mobile,
                            //  email = item.email,
                            // state_colour = item.state_colour,
                            sales_person       = item.sales_person,
                            sales_team         = item.sales_team,
                            customer_reference = item.customer_reference,
                            fiscal_position    = item.fiscal_position,
                            FullState          = item.FullState,
                            state_colour       = item.state_colour,
                            DateOrder          = item.DateOrder,
                            order_line         = json_orderline
                        };
                        App._connection.Insert(sample);
                        //App._samp.Add(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <SalesQuotationDB>() select y).ToList();
                        App.SalesQuotationListDb = details;
                    }

                    catch
                    {
                        int te = 0;
                    }
                }


                App.promotionsList = res["promotions"].ToObject <List <ActivePromotions> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <ActivePromotionsDB>();

                //var promotion_details = App._connection.Query<ActivePromotionsDB>("SELECT * from ActivePromotionsDB");

                if (App.promotionsList.Count() != 0)
                {
                    App._connection.Query <ActivePromotionsDB>("DELETE from ActivePromotionsDB");

                    foreach (var item in App.promotionsList)
                    {
                        var dblist1     = Newtonsoft.Json.JsonConvert.SerializeObject(item.list1);
                        var dblist2     = Newtonsoft.Json.JsonConvert.SerializeObject(item.list2);
                        var dbtype_list = Newtonsoft.Json.JsonConvert.SerializeObject(item.type_list);

                        var sample = new ActivePromotionsDB
                        {
                            product      = item.product,
                            name         = item.name,
                            start_date   = item.Fstart_date,
                            end_date     = item.Fend_date,
                            type         = item.type,
                            type_list    = dbtype_list,
                            list1        = dblist1,
                            list2        = dblist2,
                            Fstart_date  = item.Fstart_date,
                            Fend_date    = item.Fend_date,
                            EndDateColor = item.EndDateColor,
                        };
                        App._connection.Insert(sample);
                        //App._samp.Add(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <ActivePromotionsDB>() select y).ToList();
                        App.promotionsListDB = details;
                    }

                    catch
                    {
                        int te = 0;
                    }
                }


                App.salesOrderList = res["sale_orders"].ToObject <List <SalesOrder> >();


                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <SalesOrderDB>();

                if (App.SalesOrderListDb.Count == 0)
                {
                    foreach (var item in App.salesOrderList)
                    {
                        var json_orderline = Newtonsoft.Json.JsonConvert.SerializeObject(item.order_line);

                        var sample = new SalesOrderDB
                        {
                            customer           = item.customer,
                            next_activity      = item.next_activity,
                            name               = item.name,
                            probability        = item.probability,
                            phone              = item.phone,
                            title_action       = item.title_action,
                            expected_revenue   = item.expected_revenue,
                            payment_term       = item.payment_term,
                            team_name          = item.team_name,
                            priority           = item.priority,
                            state              = item.state,
                            street             = item.street,
                            street2            = item.street2,
                            city               = item.city,
                            country            = item.country,
                            contact_name       = item.contact_name,
                            mobile             = item.mobile,
                            email              = item.email,
                            state_colour       = item.state_colour,
                            sales_person       = item.sales_person,
                            sales_team         = item.sales_team,
                            customer_reference = item.customer_reference,
                            fiscal_position    = item.fiscal_position,
                            FullState          = item.FullState,

                            //  ColorCode = item.ColorCode,

                            DateOrder = item.DateOrder,

                            order_line = json_orderline,
                        };
                        App._connection.Insert(sample);
                        //App._samp.Add(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <SalesOrderDB>() select y).ToList();
                        App.SalesOrderListDb = details;
                    }
                    catch
                    {
                        int te = 0;
                    }
                }


                App.stageList = res["stages"].ToObject <List <stages> >();

                String colorCodeData = "";

                int cnt = 0;
                foreach (stages stateObj in res["stages"].ToObject <List <stages> >())
                {
                    try
                    {
                        colorCodeData = colorCodeData + "," + stateObj.name + "^" + colourcodes[cnt];
                    }
                    catch
                    {
                        cnt = 0;
                        continue;
                    }
                    cnt++;
                }

                Settings.StageColourCode = colorCodeData;
                App.cusdict = res["Customers"].ToObject <Dictionary <int, string> >();

                App.reasondict = res["lost_reason"].ToObject <Dictionary <int, string> >();

                App.crmleadtags = res["crm_lead_tags"].ToObject <Dictionary <int, string> >();

                App.user_gps_enabled = res["user_gps_enabled"].ToObject <Boolean>();
                App.user_gps_time    = res["user_gps_time"].ToObject <int>();

                App.locationsList = res["Location"].ToObject <List <LocationsList> >();

                return(App.crmList);
            }
            catch (Exception ea)
            {
                System.Diagnostics.Debug.WriteLine("::::: CRM Warning Message ::::  " + ea.Message);

                if (ea.Message.Contains("(Network is unreachable)") || ea.Message.Contains("NameResolutionFailure"))
                {
                    App.NetAvailable = false;
                }

                else if (ea.Message.Contains("(503) Service Unavailable"))
                {
                    App.responseState = false;
                }
                return(App.crmList);
            }
        }
示例#4
0
        public List <LeavesModel> GetMasterData()
        {
            try
            {
                JObject res = odooConnector.odooFilterDataCall("res.users", "get_master_data");

                App.user_name   = res["user_name"].ToString();
                App.user_image  = res["user_image_medium"].ToString();
                App.user_mobile = res["user_mobile"].ToString();
                App.user_email  = res["user_email"].ToString();
                App.partner_id  = res["partner_id"].ToObject <int>();
                App.employee_id = res["employee_id"].ToObject <int>();

                App.productList         = res["Products"].ToObject <List <ProductsList> >();
                App.expense_productList = res["expense_products"].ToObject <List <ExpenseProductsList> >();

                App.product_Uom   = res["product_uom"].ToObject <List <ProductUOM> >();
                App.taxList       = res["taxes"].ToObject <List <taxes> >();
                App.hr_yearList   = res["hr_years"].ToObject <List <HRYear> >();
                App.currencyList  = res["available_currency"].ToObject <List <Currency> >();
                App.leaveTypeList = res["holiday_status"].ToObject <List <LeaveType> >();

                App.employee_list = res["employees"].ToObject <List <EmployeesModel> >();

                App.access_dict = res["access_right"].ToObject <Dictionary <string, dynamic> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <UserModelDB>();

                if (App.UserListDb.Count == 0)
                {
                    var jso_tags_list            = Newtonsoft.Json.JsonConvert.SerializeObject(res["taxes"]);
                    var jso_products_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["Products"]);
                    var jso_expenseproducts_list = Newtonsoft.Json.JsonConvert.SerializeObject(res["expense_products"]);
                    var jso_product_Uomlist      = Newtonsoft.Json.JsonConvert.SerializeObject(res["product_uom"]);
                    var jso_hr_year_list         = Newtonsoft.Json.JsonConvert.SerializeObject(res["hr_years"]);
                    var jso_currency_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["available_currency"]);
                    var jso_leavetype_list       = Newtonsoft.Json.JsonConvert.SerializeObject(res["holiday_status"]);
                    var jso_employee_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["employees"]);

                    var sample = new UserModelDB
                    {
                        userid            = App.userid,
                        partnerid         = App.partner_id,
                        employeeid        = App.employee_id,
                        user_name         = App.user_name,
                        user_email        = App.user_email,
                        user_mobile       = App.user_mobile,
                        user_image_medium = App.user_image,
                        products          = jso_products_list,
                        expense_products  = jso_expenseproducts_list,
                        tax_list          = jso_tags_list,
                        product_Uom       = jso_product_Uomlist,
                        hr_year_list      = jso_hr_year_list,
                        currency_list     = jso_currency_list,
                        leavetype_list    = jso_leavetype_list,
                        employee_list     = jso_employee_list,
                    };
                    App._connection.Insert(sample);

                    try
                    {
                        var details = (from y in App._connection.Table <UserModelDB>() select y).ToList();
                        App.UserListDb = details;

                        List <ProductsList>        productslistdb         = new List <ProductsList>();
                        List <ExpenseProductsList> expense_productslistdb = new List <ExpenseProductsList>();
                        List <taxes>          taxListDb       = new List <taxes>();
                        List <ProductUOM>     product_UomDb   = new List <ProductUOM>();
                        List <Currency>       currencyListDb  = new List <Currency>();
                        List <HRYear>         hr_yearListDb   = new List <HRYear>();
                        List <LeaveType>      leaveTypeListDb = new List <LeaveType>();
                        List <EmployeesModel> employeeListDb  = new List <EmployeesModel>();

                        foreach (var item in App.UserListDb)
                        {
                            productslistdb         = JsonConvert.DeserializeObject <List <ProductsList> >(item.products);
                            expense_productslistdb = JsonConvert.DeserializeObject <List <ExpenseProductsList> >(item.expense_products);
                            taxListDb                 = JsonConvert.DeserializeObject <List <taxes> >(item.tax_list);
                            product_UomDb             = JsonConvert.DeserializeObject <List <ProductUOM> >(item.product_Uom);
                            currencyListDb            = JsonConvert.DeserializeObject <List <Currency> >(item.currency_list);
                            hr_yearListDb             = JsonConvert.DeserializeObject <List <HRYear> >(item.hr_year_list);
                            leaveTypeListDb           = JsonConvert.DeserializeObject <List <LeaveType> >(item.leavetype_list);
                            employeeListDb            = JsonConvert.DeserializeObject <List <EmployeesModel> >(item.employee_list);
                            App.userid_db             = item.userid;
                            App.ProductListDb         = productslistdb;
                            App.expense_productListDb = expense_productslistdb;
                            App.taxListDb             = taxListDb;
                            App.product_UomDb         = product_UomDb;
                            App.hr_yearListDb         = hr_yearListDb;
                            App.currencyListDb        = currencyListDb;
                            App.leaveTypeListDb       = leaveTypeListDb;
                            App.employee_idDb         = item.employeeid;
                            App.employee_listDb       = employeeListDb;
                        }
                    }
                    catch (Exception ex)
                    {
                        int i = 0;
                    }
                }

                /////// For Leaves

                App.leaves_list = res["holidays"].ToObject <List <LeavesModel> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <LeavesModelDB>();

                //  List<AttachmentFile> attlistDb = new List<AttachmentFile>();



                var leaves_details = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where sync_string = ?", "sync.png");
                if (leaves_details.Count() == 0)
                {
                    App._connection.Query <LeavesModelDB>("DELETE from LeavesModelDB");

                    foreach (var item in App.leaves_list)
                    {
                        var dbattachment_list = Newtonsoft.Json.JsonConvert.SerializeObject(item.attachment);

                        var sample = new LeavesModelDB
                        {
                            id              = item.id,
                            name            = item.name,
                            display_name    = item.display_name,
                            state           = item.state,
                            state_name      = item.state_name,
                            date_from       = item.date_from,
                            date_to         = item.date_to,
                            no_of_days      = item.no_of_days,
                            stage_colour    = item.stage_colour,
                            is_half_day     = item.is_half_day,
                            am_or_pm        = item.am_or_pm,
                            leave_structure = item.leave_structure,
                            year            = item.year,
                            employee        = item.employee,
                            report_note     = item.report_note,
                            holidays_status = item.holidays_status,
                            datefrom        = item.datefrom,
                            dateto          = item.dateto,
                            fromDate        = item.fromDate,
                            endDate         = item.endDate,
                            check_tt        = item.check_tt,
                            department      = item.department,
                            attachment_list = dbattachment_list,
                            date            = item.date,
                        };
                        App._connection.Insert(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();
                        App.leaves_listDb = details;
                    }
                    catch
                    {
                        int i = 0;
                    }
                }

                var rpc_condition = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where check_rpc_condition = ?", "false");
                if (rpc_condition.Count != 0)
                {
                    //  List<AttachmentFile> productslistdb = new List<AttachmentFile>();

                    foreach (var item in rpc_condition)
                    {
                        var sample = new LeavesModel
                        {
                            name                = item.name,
                            holidays_status     = item.holidays_status,
                            year                = item.year,
                            date_from           = item.date_from,
                            date_to             = item.date_to,
                            state               = item.state,
                            state_name          = item.state_name,
                            stage_colour        = item.stage_colour,
                            no_of_days          = item.no_of_days,
                            is_half_day         = item.is_half_day,
                            sync_string         = item.sync_string,
                            am_or_pm            = item.check_tt,
                            employee            = item.employee,
                            error_rpcTxt        = item.txt_rpc_error,
                            dbid_error_txt      = item.Dbid,
                            check_rpc_condition = item.check_rpc_condition,
                            //  attachlistfield = item.error_attachment_list,

                            attachment = JsonConvert.DeserializeObject <List <AttachmentFile> >(item.attachment_list),
                            // attachment = item.error_attachment_list,
                        };
                        App.leaves_list.Add(sample);
                    }
                }
                var data = App.leaves_list;

                /////// For Expense
                App.expense_list = res["expense"].ToObject <List <ExpenseModel> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <ExpenseModelDB>();

                var expense_details = App._connection.Query <ExpenseModelDB>("SELECT * from ExpenseModelDB where sync_string = ? OR sync_string = ?", "sync.png", "editexp.png");
                if (expense_details.Count() == 0)
                {
                    App._connection.Query <ExpenseModelDB>("DELETE from ExpenseModelDB");

                    foreach (var item in App.expense_list)
                    {
                        var expattach_list = Newtonsoft.Json.JsonConvert.SerializeObject(item.attachment);

                        var sample = new ExpenseModelDB
                        {
                            id           = item.id,
                            name         = item.name,
                            product      = item.product,
                            product_uom  = item.product_uom,
                            state        = item.state,
                            unit_price   = item.unit_price,
                            quantity     = item.quantity,
                            reference    = item.reference,
                            notes        = item.notes,
                            account      = item.account,
                            employee_id  = item.employee_id,
                            currency     = item.currency,
                            date         = item.date,
                            stage_name   = item.stage_name,
                            stage_colour = item.stage_colour,
                            half_date    = item.half_date,
                            full_date    = item.full_date,

                            attachment = expattach_list,
                        };
                        App._connection.Insert(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <ExpenseModelDB>() select y).ToList();
                        App.expense_listDb = details;
                    }
                    catch
                    {
                        int i = 0;
                    }
                }

                return(App.leaves_list);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("::::: HRM Warning Message ::::  " + ex.Message);

                if (ex.Message.Contains("(Network is unreachable)") || ex.Message.Contains("NameResolutionFailure"))
                {
                    App.NetAvailable = false;
                }
                else if (ex.Message.Contains("(503) Service Unavailable"))
                {
                    App.responseState = false;
                }
                return(App.leaves_list);
            }
        }