Example #1
0
 /// <summary>
 /// 深度克隆模式 把 数据源类的基类数据 传递给 同一基类的目标类
 /// </summary>
 /// <typeparam name="TBase">The type of the t base.</typeparam>
 /// <typeparam name="TTarget">The type of the t target.</typeparam>
 /// <param name="source">The source.</param>
 /// <returns>TTarget.</returns>
 public static TTarget AsTypeByDeepClone <TBase, TTarget>(this TBase source)
     where TBase : class
 //where TSource : class, TBase
     where TTarget : class, TBase
 {
     return(JsonSerializeHelper.DeserializeFromJson <TTarget>(JsonSerializeHelper.SerializeToJson(source)));
 }
Example #2
0
 /// <summary>
 /// 指定文件名 指定编码 指定密钥 保存实体类到独立存储区中
 /// </summary>
 /// <typeparam name="T">实体类型</typeparam>
 /// <param name="t">实体实例</param>
 /// <param name="token">序列化标识 (Null 表示使用 默认 标识名)</param>
 /// <param name="encoding">编码 (Null 表示使用 默认 编码)</param>
 /// <param name="securityKey">密钥 (Null 表示使用 默认 密钥)</param>
 public override void SaveModel <T>(T t, string token = null, string securityKey = null, Encoding encoding = null)
 {
     if (token.IfIsNullOrEmpty())
     {
         token = GetModelDefaultFileName <T>();
     }
     SaveString(JsonSerializeHelper.SerializeToJson(t), token, securityKey, encoding);
 }
        public string LoadAllCategories()
        {
            var temp =
                CarCategoryRepository.LoadEntities(
                    c => c.DelFlag == (short)DelFlagEnum.Normal && c.Status == (short)StatusEnum.Enable);
            var result = from c in temp
                         select new { c.ID, c.Name, c.ParentID };

            //return Json(result, JsonRequestBehavior.AllowGet);
            return(JsonSerializeHelper.SerializeToJson(result));
        }
Example #4
0
 /// <summary>
 /// 深度克隆 通过JSON形式 可以把 一个类型实体类数据 传递 给另一个不同类型的实体类 (只会传递两种类型实体类,属性名完全相同的属性值)
 /// </summary>
 /// <typeparam name="TSource">The type of the t source.</typeparam>
 /// <typeparam name="TTarget">The type of the t target.</typeparam>
 /// <param name="source">The source.</param>
 /// <returns>TTarget.</returns>
 public static TTarget DeepClone <TSource, TTarget>(this TSource source)
     where TSource : class
     where TTarget : class
 {
     return(JsonSerializeHelper.DeserializeFromJson <TTarget>(JsonSerializeHelper.SerializeToJson(source)));
 }
Example #5
0
 public string GetPermissionJson(string EmployeeNo)
 {
     return(JsonSerializeHelper.SerializeToJson(GetPermission(EmployeeNo)));
 }
Example #6
0
        public string GetReportData(int billType, int Time, int departmentID, string operation, string StartTime = "", string EndTime = "")
        {
            var employee = Marisfrolg.Public.Common.GetEmployeeInfo();

            //我搁置的单
            if (operation == "1")
            {
                List <FeeBillModelRef> AllModel = new List <FeeBillModelRef>();
                var Temp1 = new FeeBill().ReturnShelveNo(employee.EmployeeName);
                var Temp2 = new NoticeBill().ReturnShelveNo(employee.EmployeeNo);
                var Temp3 = new BorrowBill().ReturnShelveNo(employee.EmployeeNo);
                var Temp4 = new RefundBill().ReturnShelveNo(employee.EmployeeNo);

                foreach (var item1 in Temp1)
                {
                    FeeBillModelRef TempModel = new FeeBillModelRef()
                    {
                        BillNo = item1.BillNo, PageName = "费用报销单", Creator = item1.Creator, Owner = item1.Owner, TotalMoney = item1.TotalMoney, StringTime = item1.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item1.CreateTime, PersonInfo = new PersonInfo()
                        {
                            DepartmentCode = item1.PersonInfo.DepartmentCode, Department = item1.PersonInfo.Department
                        }
                    };
                    AllModel.Add(TempModel);
                }
                foreach (var item2 in Temp2)
                {
                    FeeBillModelRef TempModel = new FeeBillModelRef()
                    {
                        BillNo = item2.BillNo, PageName = "付款通知书", Creator = item2.Creator, Owner = item2.Owner, TotalMoney = item2.TotalMoney, StringTime = item2.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item2.CreateTime, PersonInfo = new PersonInfo()
                        {
                            DepartmentCode = item2.PersonInfo.DepartmentCode, Department = item2.PersonInfo.Department
                        }
                    };
                    AllModel.Add(TempModel);
                }
                foreach (var item3 in Temp3)
                {
                    FeeBillModelRef TempModel = new FeeBillModelRef()
                    {
                        BillNo = item3.BillNo, PageName = "借款单", Creator = item3.Creator, Owner = item3.Owner, TotalMoney = item3.TotalMoney, StringTime = item3.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item3.CreateTime, PersonInfo = new PersonInfo()
                        {
                            DepartmentCode = item3.PersonInfo.DepartmentCode, Department = item3.PersonInfo.Department
                        }
                    };
                    AllModel.Add(TempModel);
                }
                foreach (var item4 in Temp4)
                {
                    FeeBillModelRef TempModel = new FeeBillModelRef()
                    {
                        BillNo = item4.BillNo, PageName = item4.RefundType.ToUpper() == "CASH" ? "现金还款" : "费用单还款", Creator = item4.Creator, Owner = item4.Owner, TotalMoney = item4.RealRefundMoney, StringTime = item4.CreateTime.ToString("yyyy-MM-dd"), CreateTime = item4.CreateTime, PersonInfo = new PersonInfo()
                        {
                            DepartmentCode = item4.PersonInfo.DepartmentCode, Department = item4.PersonInfo.Department
                        }
                    };
                    AllModel.Add(TempModel);
                }

                switch (billType)
                {
                case 0:
                    break;

                case 1:
                    AllModel.RemoveAll(c => c.PageName.Contains("付款") || c.PageName.Contains("借款") || c.PageName.Contains("还款"));
                    break;

                case 2:
                    AllModel.RemoveAll(c => c.PageName.Contains("费用报销") || c.PageName.Contains("借款") || c.PageName.Contains("还款"));
                    break;

                case 3:
                    AllModel.RemoveAll(c => c.PageName.Contains("付款") || c.PageName.Contains("费用报销") || c.PageName.Contains("还款"));
                    break;

                case 4:
                    AllModel.RemoveAll(c => c.PageName.Contains("付款") || c.PageName.Contains("借款") || c.PageName.Contains("费用报销"));
                    break;

                default:
                    break;
                }
                if (AllModel.Count > 0)
                {
                    var temp = TransformData(AllModel, 0);

                    MemoryCachingClient M = new MemoryCachingClient();
                    M.Remove(employee.EmployeeNo);
                    M.Add(employee.EmployeeNo, temp);

                    return(JsonSerializeHelper.SerializeToJson(temp));
                }
                return("{}");
            }

            object data = GetApprovalData(billType, Time, employee.EmployeeNo, departmentID.ToString(), StartTime, EndTime);

            if (data != null)
            {
                var temp = TransformData(data, billType);

                MemoryCachingClient M = new MemoryCachingClient();
                M.Remove(employee.EmployeeNo);
                M.Add(employee.EmployeeNo, temp);

                return(JsonSerializeHelper.SerializeToJson(temp));
            }
            return("{}");
            //ReportHelper helper = new ReportHelper();
            //DataTable dt = helper.GetDataTable(@"select ID,NO,NAME,SHOPCODE,CREATOR,CHANGER,AVAILABLE,LEAVE,PASSWORD,DEPID from Employee where (DEPID=" + departmentID + " or 0=" + departmentID + ") and length(NO)>4 and ROWNUM<100");
            //foreach (DataColumn item in dt.Columns)
            //{
            //    if (item.ColumnName == "NAME")
            //    {
            //        item.ColumnName = "姓名";
            //    }
            //    if (item.ColumnName == "NO")
            //    {
            //        item.ColumnName = "工号";
            //    }
            //}
            //var temp = ReportHelper.ConvertDataTable(dt);
            //return JsonSerializeHelper.SerializeToJson(temp);
        }