コード例 #1
0
        /// <summary>
        /// 保存,上报的时候序列化后的Json数据
        /// </summary>
        /// <param name="MonthReportID"></param>
        private void SaveJsonData(Guid MonthReportID, Guid SysId, int FinYear, int FinMonth, ReportInstance CurrentRpt)
        {
            B_MonthlyReportJsonData Update_JsonData;

            try
            {
                Update_JsonData = B_MonthlyReportJsonDataOperator.Instance.GetMonthlyReportJsonData(MonthReportID);
            }
            catch (Exception) //去Json 表中查看下数据
            {
                Update_JsonData = null;
            }
            if (Update_JsonData != null)
            {
                //如果修改的话,顺便修改下B_MonthlyReport的字段,便于服务重构Json
                var BMR = B_MonthlyreportOperator.Instance.GetMonthlyreport(MonthReportID);


                Update_JsonData.SystemID   = SysId;
                Update_JsonData.PlanType   = "M";
                Update_JsonData.FinMonth   = FinMonth;
                Update_JsonData.FinYear    = FinYear;
                Update_JsonData.ModifyTime = DateTime.Now;

                List <DictionaryVmodel> ListObj = new List <DictionaryVmodel>();
                //这是上报页面的Json 数据
                TargetReportedControll trc = new TargetReportedControll();

                ReportInstance rpt = new ReportInstance(MonthReportID, true);
                ListObj.Add(new DictionaryVmodel("ReportInstance", rpt));                                       //
                ListObj.Add(new DictionaryVmodel("MonthDetail", trc.GetTargetDetailList(rpt, "Detail", true))); //

                ReportInstance rpt2 = new ReportInstance(MonthReportID, true);

                ListObj.Add(new DictionaryVmodel("Misstarget", trc.GetMissTargetList(rpt2, MonthReportID.ToString(), true)));
                ListObj.Add(new DictionaryVmodel("MonthReportDescription", trc.GetMonthTRptDescription(rpt2)));

                ReportInstance rpt3 = new ReportInstance(MonthReportID, true);
                ListObj.Add(new DictionaryVmodel("CurrentMisstarget", trc.GetCurrentMissTargetList(rpt3, MonthReportID.ToString(), true)));

                StringBuilder sb = new StringBuilder();
                sb.Append(JsonHelper.Serialize(ListObj)); // 追加所有的出来的数据
                Update_JsonData.ReportJsonData = sb.ToString();

                //修改的话,将查询的数据赋值为Null
                Update_JsonData.QuerryCurrentMissJsonData = string.Empty;
                Update_JsonData.QuerryDetaileJsonData     = string.Empty;
                Update_JsonData.QuerryMissJsonData        = string.Empty;
                Update_JsonData.QuerryReturnJsonData      = string.Empty;
                Update_JsonData.QuerrySumJsonData         = string.Empty;
                //这里记录 上传后的Json数据
                B_MonthlyReportJsonDataOperator.Instance.UpdateMonthlyReportJsonData(Update_JsonData);

                //让服务重新计算。
                BMR.DataOptimizationJson = string.Empty;
                B_MonthlyreportOperator.Instance.UpdateMonthlyreport(BMR);
            }
            else
            {
                //新增数据
                B_MonthlyReportJsonData JsonData = new B_MonthlyReportJsonData();
                JsonData.ID         = MonthReportID;
                JsonData.SystemID   = SysId;
                JsonData.PlanType   = "M";
                JsonData.FinMonth   = FinMonth;
                JsonData.FinYear    = FinYear;
                JsonData.CreateTime = DateTime.Now;

                List <DictionaryVmodel> ListObj = new List <DictionaryVmodel>();

                //这是上报页面的Json 数据
                TargetReportedControll trc = new TargetReportedControll();

                ReportInstance rpt = new ReportInstance(MonthReportID, true);
                ListObj.Add(new DictionaryVmodel("ReportInstance", rpt));                                       //
                ListObj.Add(new DictionaryVmodel("MonthDetail", trc.GetTargetDetailList(rpt, "Detail", true))); //

                ReportInstance rpt2 = new ReportInstance(MonthReportID, true);
                ListObj.Add(new DictionaryVmodel("Misstarget", trc.GetMissTargetList(rpt2, MonthReportID.ToString(), true)));
                ListObj.Add(new DictionaryVmodel("MonthReportDescription", trc.GetMonthTRptDescription(rpt2)));

                ReportInstance rpt3 = new ReportInstance(MonthReportID, true);
                ListObj.Add(new DictionaryVmodel("CurrentMisstarget", trc.GetCurrentMissTargetList(rpt3, MonthReportID.ToString(), true)));

                StringBuilder sb = new StringBuilder();
                sb.Append(JsonHelper.Serialize(ListObj)); // 追加所有的出来的数据
                JsonData.ReportJsonData = sb.ToString();

                //这里记录 上传后的Json数据
                B_MonthlyReportJsonDataOperator.Instance.AddMonthlyReportJsonData(JsonData);
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存,上报的时候序列化后的Json数据
        /// </summary>
        /// <param name="MonthReportID"></param>
        private void SaveJsonData(Guid MonthReportID)
        {
            B_MonthlyReportJsonData Update_JsonData;
            ReportInstance          CurrentRpt = new ReportInstance(MonthReportID, true);

            try
            {
                Update_JsonData = B_MonthlyReportJsonDataOperator.Instance.GetMonthlyReportJsonData(MonthReportID);
            }
            catch (Exception ex)//去Json 表中查看下数据
            {
                Update_JsonData = null;
            }

            if (Update_JsonData != null)
            {
                Update_JsonData.SystemID   = SysId;
                Update_JsonData.PlanType   = "M";
                Update_JsonData.FinMonth   = FinMonth;
                Update_JsonData.FinYear    = FinYear;
                Update_JsonData.ModifyTime = DateTime.Now;

                List <DictionaryVmodel> ListObj = new List <DictionaryVmodel>();

                TargetReportedControll trc = new TargetReportedControll();

                //这是上报页面的Json 数据

                if (!string.IsNullOrEmpty(Update_JsonData.ReportJsonData))
                {
                    ListObj = JsonHelper.Deserialize <List <DictionaryVmodel> >(Update_JsonData.ReportJsonData);

                    ListObj.ForEach(L =>
                    {
                        if (L.Name == "Misstarget")
                        {
                            L.ObjValue = trc.GetMissTargetList(CurrentRpt, MonthReportID.ToString(), true);
                        }

                        if (L.Name == "CurrentMisstarget")
                        {
                            L.ObjValue = trc.GetCurrentMissTargetList(CurrentRpt, MonthReportID.ToString(), true);
                        }
                    });
                }
                else
                {
                    ListObj.Add(new DictionaryVmodel("ReportInstance", CurrentRpt));                                       //
                    ListObj.Add(new DictionaryVmodel("MonthDetail", trc.GetTargetDetailList(CurrentRpt, "Detail", true))); //
                    ListObj.Add(new DictionaryVmodel("Misstarget", trc.GetMissTargetList(CurrentRpt, MonthReportID.ToString(), true)));
                    ListObj.Add(new DictionaryVmodel("MonthReportDescription", trc.GetMonthTRptDescription(CurrentRpt)));
                    ListObj.Add(new DictionaryVmodel("CurrentMisstarget", trc.GetCurrentMissTargetList(CurrentRpt, MonthReportID.ToString(), true)));
                }

                StringBuilder sb = new StringBuilder();
                sb.Append(JsonHelper.Serialize(ListObj)); // 追加所有的出来的数据
                Update_JsonData.ReportJsonData = sb.ToString();

                //这里记录 上传后的Json数据
                B_MonthlyReportJsonDataOperator.Instance.UpdateMonthlyReportJsonData(Update_JsonData);
            }
            else
            {
                //新增数据
                B_MonthlyReportJsonData JsonData = new B_MonthlyReportJsonData();
                JsonData.ID         = MonthReportID;
                JsonData.SystemID   = SysId;
                JsonData.PlanType   = "M";
                JsonData.FinMonth   = FinMonth;
                JsonData.FinYear    = FinYear;
                JsonData.CreateTime = DateTime.Now;

                List <DictionaryVmodel> ListObj = new List <DictionaryVmodel>();

                //这是上报页面的Json 数据
                TargetReportedControll trc = new TargetReportedControll();
                ListObj.Add(new DictionaryVmodel("ReportInstance", CurrentRpt));                                       //
                ListObj.Add(new DictionaryVmodel("MonthDetail", trc.GetTargetDetailList(CurrentRpt, "Detail", true))); //
                ListObj.Add(new DictionaryVmodel("Misstarget", trc.GetMissTargetList(CurrentRpt, MonthReportID.ToString(), true)));
                ListObj.Add(new DictionaryVmodel("MonthReportDescription", trc.GetMonthTRptDescription(CurrentRpt)));
                ListObj.Add(new DictionaryVmodel("CurrentMisstarget", trc.GetCurrentMissTargetList(CurrentRpt, MonthReportID.ToString(), true)));

                StringBuilder sb = new StringBuilder();
                sb.Append(JsonHelper.Serialize(ListObj)); // 追加所有的出来的数据
                JsonData.ReportJsonData = sb.ToString();

                //这里记录 上传后的Json数据
                B_MonthlyReportJsonDataOperator.Instance.AddMonthlyReportJsonData(JsonData);
            }
        }