/// <summary>
        /// Returns a JSON representation of our viewmodels. You'd want to use a library instead of doing this manually.
        /// </summary>
        private string GetJson(CustomerCollectionModel customerCollectionModel)
        {
            var jsonBuilder = new StringBuilder();
            jsonBuilder.Append("{ \"customers\": [");
            IList<string> customerModelJsonStrings = new List<string>();
            foreach (var customerModel in customerCollectionModel.customers)
            {
                // This will render something like: { 'firstName': 'John', 'lastName': 'Doe', 'exclusiveMember': true }
                customerModelJsonStrings.Add("{ \"firstName\": \"" + customerModel.firstName + "\", \"lastName\": \"" + customerModel.lastName + "\", \"exclusiveMember\": " + (customerModel.exclusiveMember ? "true }" : "false }"));
            }

            jsonBuilder.Append(string.Join(", ", customerModelJsonStrings.ToArray()));
            jsonBuilder.Append("] }");
            return jsonBuilder.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            customersRepeater.ItemDataBound += OnCustomersRepeaterItemDataBound;

            var model = new CustomerCollectionModel
                            {
                                customers = new[]
                                                {
                                                    new CustomerModel {firstName = "John", lastName = "Doe", exclusiveMember = true},
                                                    new CustomerModel {firstName = "Jane", lastName = "Doe", exclusiveMember = false}
                                                }
                            };

            modelHiddenField.Value = GetJson(model);
            customersRepeater.DataSource = model.customers;
            customersRepeater.DataBind();
        }
        /// <summary>
        /// Returns a JSON representation of our viewmodels. You'd want to use a library instead of doing this manually.
        /// </summary>
        private string GetJson(CustomerCollectionModel customerCollectionModel)
        {
            var jsonBuilder = new StringBuilder();

            jsonBuilder.Append("{ \"customers\": [");
            IList <string> customerModelJsonStrings = new List <string>();

            foreach (var customerModel in customerCollectionModel.customers)
            {
                // This will render something like: { 'firstName': 'John', 'lastName': 'Doe', 'exclusiveMember': true }
                customerModelJsonStrings.Add("{ \"firstName\": \"" + customerModel.firstName + "\", \"lastName\": \"" + customerModel.lastName + "\", \"exclusiveMember\": " + (customerModel.exclusiveMember ? "true }" : "false }"));
            }

            jsonBuilder.Append(string.Join(", ", customerModelJsonStrings.ToArray()));
            jsonBuilder.Append("] }");
            return(jsonBuilder.ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            customersRepeater.ItemDataBound += OnCustomersRepeaterItemDataBound;

            var model = new CustomerCollectionModel
            {
                customers = new[]
                {
                    new CustomerModel {
                        firstName = "John", lastName = "Doe", exclusiveMember = true
                    },
                    new CustomerModel {
                        firstName = "Jane", lastName = "Doe", exclusiveMember = false
                    }
                }
            };

            modelHiddenField.Value       = GetJson(model);
            customersRepeater.DataSource = model.customers;
            customersRepeater.DataBind();
        }
        public ActionResult configplatchart(string unit, string items, int?isguoup, string select1, string select2) //,int? index, int? config, int? isguoup,
        {
            dynamic data = new System.Dynamic.ExpandoObject();

            string[]    array = items.Split(',');
            List <long> ids   = new List <long>();

            foreach (var item in array)
            {
                if (item != "")
                {
                    ids.Add(long.Parse(item));
                }
            }
            var list = accountService.UCGetPlatChartPoints(Masterpage.CurrUser.client_code, unit, ids).Distinct().ToList();


            #region  处理组合采集点
            List <CustomerCollectionModel> models = new List <CustomerCollectionModel>();
            var t = items;
            if (list != null && list.Count > 0)
            {
                if (t == "7,8,9")
                {
                    #region 进水监管 -I和(L)组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I"))
                        {
                            halfname = item.collent_point_name.Replace("-I", "(L)");
                        }
                        if (item.collent_point_name.EndsWith("(L)"))
                        {
                            halfname = item.collent_point_name.Replace("(L)", "-I");
                        }
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1   = item.CustomerCollectionCode;
                            item.customer_point_code2   = half.CustomerCollectionCode;
                            item.point_html1            = item.collent_point_html;
                            item.point_html2            = half.collent_point_html;
                            item.point_remark1          = item.collent_point_remark;
                            item.point_remark2          = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else if (t == "14, 15, 16")
                {
                    #region 水质管理 -I和-E组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I"))
                        {
                            halfname = item.collent_point_name.Replace("-I", "-E");
                        }
                        if (item.collent_point_name.EndsWith("-E"))
                        {
                            halfname = item.collent_point_name.Replace("-E", "-I");
                        }
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1   = item.CustomerCollectionCode;
                            item.customer_point_code2   = half.CustomerCollectionCode;
                            item.point_html1            = item.collent_point_html;
                            item.point_html2            = half.collent_point_html;
                            item.point_remark1          = item.collent_point_remark;
                            item.point_remark2          = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else
                {
                    #region  组合
                    foreach (var item in list)
                    {
                        models.Add(item);
                    }
                    #endregion
                }
            }
            #endregion


            data.unit    = unit;
            data.items   = items;
            data.select1 = select1;
            data.select2 = select2;
            #region 初始化是否组合
            var md = models.FirstOrDefault(p => p.CustomerCollectionCode == select1 + "," + select2);
            if (md != null)
            {
                isguoup = 1;
            }
            data.isguoup = isguoup;
            #endregion
            data.list = models;
            return(PartialView(data));
        }
Example #6
0
        public ActionResult configplatchart(string unit, string items, int? isguoup, string select1, string select2)
        {
            dynamic data = new System.Dynamic.ExpandoObject();
            string[] array = items.Split(',');
            List<long> ids = new List<long>();
            foreach (var item in array)
            {
                if (item != "") ids.Add(long.Parse(item));
            }
            var list = accountService.UCGetPlatChartPoints(Masterpage.CurrUser.client_code, unit, ids).Distinct().ToList();

            #region  处理组合采集点
            List<CustomerCollectionModel> models = new List<CustomerCollectionModel>();
            var t = items;
            if (list != null && list.Count > 0)
            {
                if (t == "7,8,9")
                {
                    #region 进水监管 -I和(L)组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I")) halfname = item.collent_point_name.Replace("-I", "(L)");
                        if (item.collent_point_name.EndsWith("(L)")) halfname = item.collent_point_name.Replace("(L)", "-I");
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1 = item.CustomerCollectionCode;
                            item.customer_point_code2 = half.CustomerCollectionCode;
                            item.point_html1 = item.collent_point_html;
                            item.point_html2 = half.collent_point_html;
                            item.point_remark1 = item.collent_point_remark;
                            item.point_remark2 = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else if (t == "14, 15, 16")
                {
                    #region 水质管理 -I和-E组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I")) halfname = item.collent_point_name.Replace("-I", "-E");
                        if (item.collent_point_name.EndsWith("-E")) halfname = item.collent_point_name.Replace("-E", "-I");
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1 = item.CustomerCollectionCode;
                            item.customer_point_code2 = half.CustomerCollectionCode;
                            item.point_html1 = item.collent_point_html;
                            item.point_html2 = half.collent_point_html;
                            item.point_remark1 = item.collent_point_remark;
                            item.point_remark2 = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else
                {
                    #region 不组合
                    foreach (var item in list)
                    {
                        models.Add(item);
                    }
                    #endregion
                }

            }
            #endregion

            data.unit = unit;
            data.items = items;
            data.select1 = select1;
            data.select2 = select2;
            #region 初始化是否组合
            var md = models.FirstOrDefault(p => p.CustomerCollectionCode == select1 + "," + select2);
            if (md != null) isguoup = 1;
            data.isguoup = isguoup;
            #endregion
            data.list = models;
            return PartialView(data);
        }
Example #7
0
        public ActionResult configplatchart2(int? index, int? config, int? isguoup, string select1, string select2)
        {
            dynamic data = new System.Dynamic.ExpandoObject();
            int _config = config.HasValue ? config.Value : 7;
            int _index = index.HasValue ? index.Value : 1;
            var list = accountService.UCGetPlatChartPoints(Masterpage.CurrUser.client_code, _config);

            #region  处理组合采集点
            List<CustomerCollectionModel> models = new List<CustomerCollectionModel>();
            var t = _config;
            if (list != null && list.Count > 0)
            {
                if (t >= 7 && t <= 9)
                {
                    #region 进水监管 -I和(L)组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I")) halfname = item.collent_point_name.Replace("-I", "(L)");
                        if (item.collent_point_name.EndsWith("(L)")) halfname = item.collent_point_name.Replace("(L)", "-I");
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1 = item.CustomerCollectionCode;
                            item.customer_point_code2 = half.CustomerCollectionCode;
                            item.point_html1 = item.collent_point_html;
                            item.point_html2 = half.collent_point_html;
                            item.point_remark1 = item.collent_point_remark;
                            item.point_remark2 = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else if (t >= 14 && t <= 16)
                {
                    #region 水质管理 -I和-E组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        CustomerCollectionModel half = new CustomerCollectionModel();
                        string halfname = "";
                        if (item.collent_point_name.EndsWith("-I")) halfname = item.collent_point_name.Replace("-I", "-E");
                        if (item.collent_point_name.EndsWith("-E")) halfname = item.collent_point_name.Replace("-E", "-I");
                        half = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == halfname);
                        if (half != null && half.CustomerCollectionCode != "")
                        {
                            item.isgroup = 1;
                            item.customer_point_code1 = item.CustomerCollectionCode;
                            item.customer_point_code2 = half.CustomerCollectionCode;
                            item.point_html1 = item.collent_point_html;
                            item.point_html2 = half.collent_point_html;
                            item.point_remark1 = item.collent_point_remark;
                            item.point_remark2 = half.collent_point_remark;
                            item.CustomerCollectionCode = item.CustomerCollectionCode + "," + half.CustomerCollectionCode;
                            models.Add(item);
                        }
                        else
                        {
                            models.Add(item);
                        }
                    }
                    #endregion
                }
                else if (t == 17)
                {
                    #region 系统排放 D与DT组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        else
                        {
                            if (item.collent_point_code == "I601")//DWCQ排放量
                            {
                                models.Add(item);
                            }
                            else
                            {
                                string w1 = item.collent_point_name.Substring(0, 1);    //DSS
                                string wr = item.collent_point_name.Substring(1);       //SS
                                string part2 = "DT" + wr;                               //DTSS
                                var hadpart2 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_name == part2);
                                if (w1 == "D" && hadpart2 != null)                      //D和DT同时存在
                                {
                                    item.isgroup = 1;
                                    item.customer_point_code1 = item.CustomerCollectionCode;
                                    item.customer_point_code2 = hadpart2.CustomerCollectionCode;
                                    item.point_html1 = item.collent_point_html;
                                    item.point_html2 = hadpart2.collent_point_html;
                                    item.point_remark1 = item.collent_point_remark;
                                    item.point_remark2 = hadpart2.collent_point_remark;
                                    item.CustomerCollectionCode = item.CustomerCollectionCode + "," + hadpart2.CustomerCollectionCode;
                                    models.Add(item);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    #endregion
                }
                else if (t == 22)
                {
                    #region 废水回量与率组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        else
                        {
                            CustomerCollectionModel i33 = new CustomerCollectionModel();
                            if (item.collent_point_code == "I513")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I514");
                            }
                            if (item.collent_point_code == "I514")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I513");
                            }
                            if (i33 != null && i33.CustomerCollectionCode != "")
                            {
                                item.isgroup = 1;
                                item.customer_point_code1 = item.CustomerCollectionCode;
                                item.customer_point_code2 = i33.CustomerCollectionCode;
                                item.point_html1 = item.collent_point_html;
                                item.point_html2 = i33.collent_point_html;
                                item.point_remark1 = item.collent_point_remark;
                                item.point_remark2 = i33.collent_point_remark;
                                item.CustomerCollectionCode = item.CustomerCollectionCode + "," + i33.CustomerCollectionCode;
                                models.Add(item);
                            }
                            else
                            {
                                models.Add(item);
                            }
                        }
                    }
                    #endregion
                }
                else if (t == 23)
                {
                    #region 泥饼产量与率组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        else
                        {
                            CustomerCollectionModel i33 = new CustomerCollectionModel();
                            if (item.collent_point_code == "I331")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I332");
                            }
                            if (item.collent_point_code == "I332")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I331");
                            }
                            if (i33 != null && i33.CustomerCollectionCode != "")
                            {
                                item.isgroup = 1;
                                item.customer_point_code1 = item.CustomerCollectionCode;
                                item.customer_point_code2 = i33.CustomerCollectionCode;
                                item.point_html1 = item.collent_point_html;
                                item.point_html2 = i33.collent_point_html;
                                item.point_remark1 = item.collent_point_remark;
                                item.point_remark2 = i33.collent_point_remark;
                                item.CustomerCollectionCode = item.CustomerCollectionCode + "," + i33.CustomerCollectionCode;
                                models.Add(item);
                            }
                            else
                            {
                                models.Add(item);
                            }
                        }
                    }
                    #endregion
                }
                else if (t == 24)
                {
                    #region 沼气产量与率组合
                    foreach (var item in list)
                    {
                        var had = models.FirstOrDefault(p => p.customer_point_code1 == item.CustomerCollectionCode || p.customer_point_code2 == item.CustomerCollectionCode);
                        if (had != null)
                        {
                            continue;
                        }
                        else
                        {
                            CustomerCollectionModel i33 = new CustomerCollectionModel();
                            if (item.collent_point_code == "I333")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I334");
                            }
                            if (item.collent_point_code == "I334")
                            {
                                i33 = list.FirstOrDefault(p => p.StandardProcessUnitCode == item.StandardProcessUnitCode && p.collent_point_code == "I333");
                            }
                            if (i33 != null && i33.CustomerCollectionCode != "")
                            {
                                item.isgroup = 1;
                                item.customer_point_code1 = item.CustomerCollectionCode;
                                item.customer_point_code2 = i33.CustomerCollectionCode;
                                item.point_html1 = item.collent_point_html;
                                item.point_html2 = i33.collent_point_html;
                                item.point_remark1 = item.collent_point_remark;
                                item.point_remark2 = i33.collent_point_remark;
                                item.CustomerCollectionCode = item.CustomerCollectionCode + "," + i33.CustomerCollectionCode;
                                models.Add(item);
                            }
                            else
                            {
                                models.Add(item);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region 不组合
                    foreach (var item in list)
                    {
                        models.Add(item);
                    }
                    #endregion
                }

            }
            #endregion

            data.config = config;
            data.index = _index;
            data.select1 = select1;
            data.select2 = select2;
            #region 初始化是否组合
            var md = models.FirstOrDefault(p => p.CustomerCollectionCode == select1 + "," + select2);
            if (md != null) isguoup = 1;
            data.isguoup = isguoup;
            #endregion
            data.list = models;
            return PartialView(data);
        }