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); } }
public ActivePromotionDetailPage(ActivePromotionsDB item) { InitializeComponent(); // act_promo = item; List <type_list> type_listdb = new List <type_list>(); List <list1> list1db = new List <list1>(); List <list2> list2db = new List <list2>(); var json_list_type = JsonConvert.SerializeObject(item.type_list); var json_list1 = JsonConvert.SerializeObject(item.list1); var json_list2 = JsonConvert.SerializeObject(item.list2); String type_list_str = json_list_type.ToString(); String list1string = json_list1.ToString(); String list2string = json_list2.ToString(); //type_list starts here String fin_type_string = type_list_str.Replace("\\", ""); fin_type_string = fin_type_string.Substring(1); fin_type_string = fin_type_string.Remove(fin_type_string.Length - 1); JArray type_list_string = JsonConvert.DeserializeObject <JArray>(fin_type_string); //list 1 starts here String finlist1string = list1string.Replace("\\", ""); finlist1string = finlist1string.Substring(1); finlist1string = finlist1string.Remove(finlist1string.Length - 1); JArray list1_string = JsonConvert.DeserializeObject <JArray>(finlist1string); //list 2 starts here String finlist2string = list2string.Replace("\\", ""); finlist2string = finlist2string.Substring(1); finlist2string = finlist2string.Remove(finlist2string.Length - 1); JArray list2_string = JsonConvert.DeserializeObject <JArray>(finlist2string); if (list1_string != null) { foreach (JObject obj in list1_string) { list1 list1new = new list1(); try { list1new.product = obj["product"].ToString(); } catch { list1new.product = ""; } try { list1new.minimum_quantity = obj["minimum_quantity"].ToString(); } catch { list1new.minimum_quantity = ""; } try { list1new.maximum_quantity = obj["maximum_quantity"].ToString(); } catch { list1new.maximum_quantity = ""; } list1db.Add(list1new); } } if (list2_string != null) { // public string discount { get; set; } //public string product { get; set; } //public string account { get; set; } //public string quantity_free { get; set; } foreach (JObject obj in list2_string) { list2 list2new = new list2(); try { list2new.product = obj["product"].ToString(); } catch { list2new.product = ""; } try { list2new.discount = obj["discount"].ToString(); } catch { list2new.discount = ""; } try { list2new.account = obj["account"].ToString(); } catch { list2new.account = ""; } try { list2new.quantity_free = obj["quantity_free"].ToString(); } catch { list2new.quantity_free = ""; } list2db.Add(list2new); } } if (type_list_string != null) { foreach (JObject obj in type_list_string) { type_list type_listnew = new type_list(); try { type_listnew.category = obj["category"].ToString(); } catch { type_listnew.category = ""; } try { type_listnew.discount = obj["discount"].ToString(); } catch { type_listnew.discount = ""; } try { type_listnew.product = obj["product"].ToString(); } catch { type_listnew.product = ""; } try { type_listnew.total_price = obj["total_price"].ToString(); } catch { type_listnew.total_price = ""; } try { type_listnew.minimum_quantity = obj["minimum_quantity"].ToString(); } catch { type_listnew.minimum_quantity = ""; } try { type_listnew.maximum_quantity = obj["maximum_quantity"].ToString(); } catch { type_listnew.maximum_quantity = ""; } try { type_listnew.minimum_amount = obj["minimum_amount"].ToString(); } catch { type_listnew.minimum_amount = ""; } try { type_listnew.list_price = obj["list_price"].ToString(); } catch { type_listnew.list_price = ""; } type_listdb.Add(type_listnew); } } title.Text = item.name; type_val.Text = item.type; proservice_val.Text = item.product; startdate_val.Text = item.start_date; enddate_val.Text = item.end_date; if (item.type == "7_total_price_product_filter_by_quantity") { sevan_totalpricefilter_stack.IsVisible = true; sevan_totalListview.ItemsSource = type_listdb; one_dis_on_totorder_stack.IsVisible = false; two_dis_on_cat_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; } else if (item.type == "6_price_filter_quantity") { six_unitpricefilter_stack.IsVisible = true; six_unitpriceListview.ItemsSource = type_listdb; one_dis_on_totorder_stack.IsVisible = false; two_dis_on_cat_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else if (item.type == "5_pack_free_gift") { five_bypackfree_stack.IsVisible = true; fiveaaa_bypackfree2_stack.IsVisible = true; five_bypackfreeListview.ItemsSource = list1db; bypackfreeListview2.ItemsSource = list2db; five_bypackfreeListview.HeightRequest = list1db.Count * 50; bypackfreeListview2.HeightRequest = list2db.Count * 50; one_dis_on_totorder_stack.IsVisible = false; two_dis_on_cat_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else if (item.type == "4_pack_discount") { four_bypackdiscount_stack.IsVisible = true; fouraaa_bypackdiscount2_stack.IsVisible = true; four_bypackdiscountListview.ItemsSource = list1db; four_bypackdiscountListview2.ItemsSource = list2db; four_bypackdiscountListview.HeightRequest = list1db.Count * 50; four_bypackdiscountListview2.HeightRequest = list2db.Count * 50; one_dis_on_totorder_stack.IsVisible = false; two_dis_on_cat_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else if (item.type == "3_discount_by_quantity_of_product") { three_dis_by_quan_stack.IsVisible = true; three_dis_by_quanListview.ItemsSource = type_listdb; one_dis_on_totorder_stack.IsVisible = false; two_dis_on_cat_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else if (item.type == "2_discount_category") { two_dis_on_cat_stack.IsVisible = true; two_dis_on_catListview.ItemsSource = type_listdb; one_dis_on_totorder_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else if (item.type == "1_discount_total_order") { one_dis_on_totorder_stack.IsVisible = true; one_dis_on_totorderListview.ItemsSource = type_listdb; two_dis_on_cat_stack.IsVisible = false; three_dis_by_quan_stack.IsVisible = false; four_bypackdiscount_stack.IsVisible = false; fouraaa_bypackdiscount2_stack.IsVisible = false; five_bypackfree_stack.IsVisible = false; fiveaaa_bypackfree2_stack.IsVisible = false; six_unitpricefilter_stack.IsVisible = false; sevan_totalpricefilter_stack.IsVisible = false; } else { } var backRecognizer = new TapGestureRecognizer(); backRecognizer.Tapped += (s, e) => { PopupNavigation.PopAsync(); // Navigation.PopAllPopupAsync(); // Navigation.PushAsync(new CalendarPage()); // App.Current.MainPage = new MasterPage(new CalendarPage()); }; backImg.GestureRecognizers.Add(backRecognizer); }