public void SetValue()
 {
     IDictionary<string, int> Test = new Dictionary<string, int>();
     Test.Add("Q", 4);
     Test.Add("Z", 2);
     Test.Add("C", 3);
     Test.Add("A", 1);
     Assert.Equal(4, Test.GetValue("Q"));
     Test.SetValue("Q", 40);
     Assert.Equal(40, Test.GetValue("Q"));
 }
Пример #2
0
        public void Push()
        {
            var entites     = this.GetDbContext <ProjectEntities>();
            var productList = entites.Set <S_E_Product>().Where(a => a.ProjectInfoID == this.ProjectInfoID).ToList();

            foreach (var item in this.T_EXE_MettingSign_ResultList.ToList())
            {
                var product = productList.FirstOrDefault(a => a.ID == item.ProductID);//this.ProjectEntites.Set<S_E_Product>().Find(item.ProductID);
                if (product != null)
                {
                    product.CoSignState        = Project.Logic.CoSignState.SignComplete.ToString();
                    product.CounterSignAuditID = this.ID;
                    var coUserList = new List <Dictionary <string, object> >();
                    foreach (var member in this.T_EXE_MettingSign_ProjectGroupMembers.ToList())
                    {
                        var coUser = new Dictionary <string, object>();
                        coUser.SetValue("MajorValue", member.MajorCode);
                        coUser.SetValue("MajorName", member.Major);
                        coUser.SetValue("UserID", member.MettingUser);
                        coUser.SetValue("UserName", member.MettingUserName);
                        coUser.SetValue("SignDate", member.SignDate);
                        coUserList.Add(coUser);
                    }
                    product.CoSignUser = JsonHelper.ToJson(coUserList);
                    product.UpdateVersison();

                    //当只有原图校审,通过后,同步更新拆分图的签名信息、校审状态
                    var children = productList.Where(a => a.ParentID == product.ID && a.ParentVersion == product.Version).ToList();
                    foreach (var child in children)
                    {
                        child.CoSignState        = Project.Logic.CoSignState.SignComplete.ToString();
                        child.CounterSignAuditID = this.ID;
                        child.CoSignUser         = product.CoSignUser;
                        child.UpdateVersison();
                    }
                }
            }
        }
        protected override void AfterGetData(DataTable dt, bool isNew, string upperVersionID)
        {
            var enumService  = FormulaHelper.GetService <IEnumService>();
            var UpperVersion = HttpContext.Request["UpperVersion"];

            if (isNew && String.IsNullOrEmpty(UpperVersion)) //新增时候并且不是升版的情况下才默认增加子项内容
            {
                if (dt.Rows.Count > 0 && dt.Columns.Contains("SubProjectList"))
                {
                    var subProjectList = new List <Dictionary <string, object> >();
                    if (dt.Columns.Contains("ProjectInfoID"))
                    {
                        var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(dt.Rows[0]["ProjectInfoID"].ToString());
                        if (projectInfo != null && projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_TemporaryMode") == TrueOrFalse.True.ToString())
                        {
                            var phaseInfo     = projectInfo.PhaseValue.Split(',');
                            var phaesNameInfo = projectInfo.PhaseName.Split(',');
                            for (int i = 0; i < phaseInfo.Length; i++)
                            {
                                var phaseValue = phaseInfo[i];
                                if (string.IsNullOrEmpty(phaseValue))
                                {
                                    continue;
                                }
                                var phaseName = enumService.GetEnumText("Project.Phase", phaseValue);
                                var item      = new Dictionary <string, object>();
                                item.SetValue("Name", phaseName);
                                item.SetValue("PhaseValue", phaseValue);
                                item.SetValue("Code", FormulaHelper.CreateGuid());
                                item.SetValue("Area", projectInfo.Proportion);
                                subProjectList.Add(item);
                            }
                        }
                    }
                    dt.Rows[0]["SubProjectList"] = JsonHelper.ToJson(subProjectList);
                }
            }
        }
Пример #4
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                var sql = string.Format(@"select * from S_F_DeptFundPlan where BelongYear={0} and BelongMonth={1} and ChargerDept='{2}'  order by VersionNumber desc",
                                        dic.GetValue("BelongYear"), dic.GetValue("BelongMonth"), dic.GetValue("ChargerDept"));
                var dt = this.EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    dic.SetValue("VersionNumber", "1");
                }
                else
                {
                    var list = FormulaHelper.DataTableToListDic(dt);
                    //if (list.Exists(d => d.GetValue("FlowPhase") != "End"))
                    //{
                    //    throw new Formula.Exceptions.BusinessValidationException(string.Format("部门【{0}】【{1}年{2}月】有正在审核中的计划编制,无法提交!", dic.GetValue("ChargerDeptName"), dic.GetValue("BelongYear"), dic.GetValue("BelongMonth")));
                    //}

                    var newVersionNumber = Convert.ToInt32(list[0].GetValue("VersionNumber")) + 1;
                    dic.SetValue("VersionNumber", newVersionNumber.ToString());
                }
            }

            if (string.IsNullOrWhiteSpace(dic.GetValue("Detail")))
            {
                dic.SetValue("ReceiveValue", "0");
                dic.SetValue("PaymentValue", "0");
            }
            else
            {
                var list         = JsonHelper.ToList(dic.GetValue("Detail"));
                var receiveValue = 0m;
                var paymentValue = 0m;
                var amount       = 0m;
                foreach (var item in list)
                {
                    amount = Convert.ToDecimal(item.GetValue("Amount"));
                    switch (item.GetValue("FundType"))
                    {
                    case "Receive":
                        receiveValue += amount;
                        break;

                    case "Payment":
                        paymentValue += amount;
                        break;

                    default:
                        break;
                    }
                }
                receiveValue = Math.Round(receiveValue, 2);
                paymentValue = Math.Round(paymentValue, 2);
                dic.SetValue("ReceiveValue", receiveValue.ToString());
                dic.SetValue("PaymentValue", paymentValue.ToString());
            }
        }
Пример #5
0
        public Dictionary <string, object> ToDic()
        {
            var result = new Dictionary <string, object>();

            result.SetValue("type", Type);
            if (!String.IsNullOrEmpty(BackgroundColor))
            {
                result.SetValue("backgroundColor", BackgroundColor);
            }
            if (!String.IsNullOrEmpty(className))
            {
                result.SetValue("className", className);
            }
            if (!String.IsNullOrEmpty(BorderColor))
            {
                result.SetValue("borderColor", BorderColor);
            }
            if (this.Is3D)
            {
                result.SetValue("options3d", this.options3D);
            }
            return(result);
        }
Пример #6
0
        public S_EP_BudgetVersion_Detail AddChildNode(bool isDetail = false)
        {
            var allowAddChild = this.DB.ExecuteScalar(String.Format("SELECT AllowAddChild FROM {1}.dbo.S_EP_DefineBudget_Subject WHERE ID='{0}'",
                                                                    this.ModelDic.GetValue("BudgetDetailDefineID"), this.InfrasDB.DbName));

            if (!isDetail)
            {
                //新增明细数据的时候不校验定义结构
                //任意CBS节点都允许添加明细
                if (allowAddChild != null && allowAddChild != DBNull.Value)
                {
                    if (allowAddChild.ToString() == "0")
                    {
                        throw new Formula.Exceptions.BusinessValidationException("【" + this.ModelDic.GetValue("Name") + "】不允许新增子节点");
                    }
                }
            }
            var child = new Dictionary <string, object>();

            child.SetValue("ID", FormulaHelper.CreateGuid());
            child.SetValue("Name", "新建节点");
            return(this.AddChildNode(child, isDetail));
        }
Пример #7
0
        /// <summary>
        /// 科目费用分布
        /// </summary>
        /// <returns></returns>
        private Dictionary <string, object> GetContractSubjectPieData(string costUnitArr)
        {
            var sourceDt = this.SQLDB.ExecuteDataTable(string.Format(@"select sum(isnull(ApplyValue,0)) valueField, SubjectName nameField from S_EP_ReimbursementApply_Details detail
                                                       left join S_EP_ReimbursementApply apply on apply.ID = detail.S_EP_ReimbursementApplyID
                                                       where apply.FlowPhase = 'End' and ProjectInfo in ('{0}') group by SubjectName", costUnitArr));

            var chart   = HighChartHelper.CreatePieChart("", "", sourceDt);
            var result  = chart.Render();
            var credits = new Dictionary <string, object>();

            credits.SetValue("enabled", false);
            result.SetValue("credits", credits);
            return(result);
        }
Пример #8
0
        public ActionResult Config()
        {
            var pbsEnum  = EnumBaseHelper.GetEnumDef("Base.PBSType");
            var enumList = new List <Dictionary <string, object> >();

            var cbsdic = new Dictionary <string, object>();

            cbsdic.SetValue("value", "CBS");
            cbsdic.SetValue("text", "费用科目");
            cbsdic.SetValue("sortindex", 0);
            enumList.Add(cbsdic);

            foreach (var item in pbsEnum.EnumItem.ToList())
            {
                var dic = new Dictionary <string, object>();
                dic.SetValue("value", item.Code);
                dic.SetValue("text", item.Name);
                dic.SetValue("sortindex", item.SortIndex);
                enumList.Add(dic);
            }
            ViewBag.CBSNodeTypeEnum = JsonHelper.ToJson(enumList);
            return(View());
        }
Пример #9
0
        public S_EP_DefineSubject AddBrotherNode(Dictionary <string, object> child)
        {
            if (this.ParentNode == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到父节点,无法新增科目");
            }
            var sortIndex = String.IsNullOrEmpty(this.ModelDic.GetValue("SortIndex")) ? 0m : Convert.ToDecimal(this.ModelDic.GetValue("SortIndex"));

            child.SetValue("SortIndex", sortIndex + 1);
            string sql = "update S_EP_DefineSubject set SortIndex= SortIndex+1 where ParentID='{0}' and SortIndex>{1}";

            this.InfrasDB.ExecuteNonQuery(String.Format(sql, this.ModelDic.GetValue("ParentID"), sortIndex));
            return(this.ParentNode.AddChildNode(child));
        }
        public JsonResult GetList()
        {
            string queryData        = this.Request["QueryData"];
            var    startDate        = new DateTime(DateTime.Now.Year, 1, 1).ToShortDateString();
            var    endDate          = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1).ToShortDateString();
            string analysisValue    = ContractAnlysisType.ContractValue.ToString();
            string sql              = @" select top 20 * from (select S_M_ContractInfo.ID ContractID,S_M_ContractInfo.PartyA ,
Name,ProductionDept as DeptID,
ProductionDeptName as DeptName,SignDate,ContractRMBValue as ContractValue,isnull(ReceiptValue,0) as ReceiptValue,
isnull(ContractRMBValue,0)-isnull(SumReceiptValue,0)-isnull(SumBadDebtValue,0) as RemainContractValue,
isnull(SumInvoiceValue,0)-isnull(SumReceiptValue,0)-isnull(SumBadDebtValue,0) as ReceivableValue
from S_M_ContractInfo
 left join (select Sum(ReceiptValue) as ReceiptValue,ContractInfo from S_M_Receipt
{0} group by ContractInfo) ReceiptInfo on ReceiptInfo.ContractInfo = S_M_ContractInfo.ID
{1}) TableInfo order by {2} desc ";
            string contractWhereStr = " where SignDate is not null ";
            string receiptWhereStr  = string.Empty;

            if (!String.IsNullOrEmpty(queryData))
            {
                var query    = JsonHelper.ToObject(queryData);
                var deptID   = query.GetValue("DeptID");
                var lastYear = String.IsNullOrEmpty(query.GetValue("StartYear")) ? 1 : Convert.ToInt32(query.GetValue("StartYear"));
                startDate = new DateTime(DateTime.Now.Year - lastYear + 1, 1, 1).ToShortDateString();
                if (!String.IsNullOrEmpty(query.GetValue("AnlysisValue")))
                {
                    analysisValue = query.GetValue("AnlysisValue");
                }
                if (analysisValue == ContractAnlysisType.ContractValue.ToString())
                {
                    contractWhereStr += " and SignDate >='" + startDate + "' and SignDate<='" + endDate + "' ";
                }
                else if (analysisValue == ContractAnlysisType.ReceiptValue.ToString())
                {
                    receiptWhereStr  += " where ReceiptDate>='" + startDate + "' and ReceiptDate<='" + endDate + "'";
                    contractWhereStr += " and ReceiptValue>0  ";
                }
                if (!String.IsNullOrEmpty(deptID) && deptID != Config.Constant.OrgRootID)
                {
                    contractWhereStr += " and ProductionDept='" + deptID + "'";
                }
            }
            sql = String.Format(sql, receiptWhereStr, contractWhereStr, analysisValue);
            var data   = this.SqlHelper.ExecuteDataTable(sql);
            var result = new Dictionary <string, object>();

            result.SetValue("data", data);
            result["chartData"] = createChartOption(data, analysisValue);
            return(Json(result));
        }
Пример #11
0
        private Dictionary <string, object> CreateYAxis(string color, string text, string format, bool opposite = false)
        {
            var result           = new Dictionary <string, object>();
            var yAxisLabels      = new Dictionary <string, object>();
            var yAxisLabelsStyle = new Dictionary <string, object>();

            yAxisLabelsStyle.SetValue("color", color);
            yAxisLabelsStyle.SetValue("format", format);
            yAxisLabels.SetValue("style", yAxisLabelsStyle);
            result.SetValue("labels", yAxisLabels);
            var yAxisTitle      = new Dictionary <string, object>();
            var yAxisTitleStyle = new Dictionary <string, object>();

            yAxisTitleStyle.SetValue("color", color);
            yAxisTitle.SetValue("text", text);
            yAxisTitle.SetValue("style", yAxisTitleStyle);
            result.SetValue("title", yAxisTitle);
            if (opposite)
            {
                result.SetValue("opposite", opposite);
            }
            return(result);
        }
Пример #12
0
        /// <summary>
        /// 解析出类型定义string
        /// </summary>
        public string GetTypeName(Type type)
        {
            if (TypeNameCache.TryGetValue(type, out var tpName))
            {
                return(tpName);
            }

            //-- GenericType
            if (type.IsGenericType)
            {
                var nullableType = Nullable.GetUnderlyingType(type); //if NullableType
                if (nullableType != null)
                {
                    tpName = GetTypeName(nullableType) + "?";
                }
                else
                {
                    tpName = string.Format("{0}{1}<{2}>", type.Namespace?.StartsWith("System") == true ? null : type.Namespace + ".",
                                           type.Name.Substring(0, type.Name.IndexOf('`')), string.Join(", ", type.GetGenericArguments().Select(GetTypeName)));
                }

                return(TypeNameCache.SetValue(type, tpName));
            }

            switch (type.Name) //Friendly name
            {
            case "Boolean":
                return("bool");

            case "String":
                return("string");

            case "Int32":
                return("int");

            case "Int64":
                return("long");

            case "Decimal":
                return("decimal");

            case "Object":
                return("object");

            case "Void":
                return("void");
            }

            return(type.FullName ?? type.Name);
        }
Пример #13
0
        public void SetValue()
        {
            var Test = new Dictionary <string, int>
            {
                { "Q", 4 },
                { "Z", 2 },
                { "C", 3 },
                { "A", 1 }
            };

            Assert.Equal(4, Test.GetValue("Q"));
            Test.SetValue("Q", 40);
            Assert.Equal(40, Test.GetValue("Q"));
        }
Пример #14
0
        public Dictionary <string, object> GetParamDataSource(Dictionary <string, object> inputData)
        {
            var   result = new Dictionary <string, object>();
            Regex reg    = new Regex("\\{[0-9a-zA-Z_\\.]*\\}");

            foreach (var item in this.ParamDefineList)
            {
                if (String.IsNullOrEmpty(item.GetValue("SQL")))
                {
                    continue;
                }
                var sql = reg.Replace(item.GetValue("SQL"), (Match m) =>
                {
                    var value       = m.Value.Trim('{', '}');
                    var sourceNames = value.Split('.');
                    if (sourceNames.Length <= 1)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("【" + item.GetValue("Code") + "】的变量设置必须要求为XXX.XXX的格式,请检查配置");
                    }
                    else
                    {
                        if (sourceNames[0] != InputPre && sourceNames[0] != FormPre)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("【" + item.GetValue("Code") + "】数据源的变量前缀只能是Input或Form 检查配置");
                        }
                        return(inputData.GetValue(sourceNames[1]));
                    }
                });
                object obj = 0;
                try
                {
                    obj = this.DB.ExecuteScalar(sql);
                }
                catch (Exception exp)
                {
                    throw new Formula.Exceptions.BusinessValidationException("参数数据源【" + item.GetValue("Code") + "】的SQL语句执行错误,请检查配置信息【" + exp.Message + "】");
                }
                var dRes = 0m;
                if (obj == null || obj == DBNull.Value)
                {
                    obj = 0;
                }
                if (!decimal.TryParse(obj.ToString(), out dRes))
                {
                    throw new BusinessException("编号为【" + item.GetValue("Code") + "】查询结果非数值");
                }
                result.SetValue(item.GetValue("Code"), dRes);
            }
            return(result);
        }
        protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew)
        {
            if (!isNew)
            {
                var plan = this.GetEntityByID(dic.GetValue("ID"));
                if (plan.FactValue.HasValue && plan.FactValue.Value > 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("计划【" + plan.PaymentObjName + "】已经有付款,无法修改。");
                }
                if (plan.State == PlanPaymentState.UnFinished.ToString())
                {
                    throw new Formula.Exceptions.BusinessValidationException("计划【" + plan.PaymentObjName + "】未完成,无法修改。");
                }
            }
            //base.BeforeSave(dic, formInfo, isNew);
            var date = DateTime.Now;

            DateTime.TryParse(dic.GetValue("PlanDate"), out date);

            dic.SetValue("BelongYear", date.Year.ToString());
            dic.SetValue("BelongMonth", date.Month.ToString());
            dic.SetValue("BelongQuarter", ((date.Month - 1) / 3 + 1).ToString());
            //计划付款款不能大于可付款(付款项-该付款项实际付款合计)
            var planValue   = String.IsNullOrEmpty(dic.GetValue("PlanValue")) ? 0m : Convert.ToDecimal(dic.GetValue("PlanValue"));
            var remainValue = 0m;
            var paymentObj  = this.GetEntityByID <S_P_ContractInfo_PaymentObj>(dic.GetValue("PaymentObj"));

            if (paymentObj != null)
            {
                var paymentValue = Convert.ToDecimal(paymentObj.PlanPaymentValue);
                remainValue = paymentValue - Convert.ToDecimal(paymentObj.S_P_ContractInfo_PaymentObj_PaymentPlan.Where(a => a.ID != dic.GetValue("ID")).Sum(a => a.FactValue));
                if (planValue > remainValue)
                {
                    throw new Formula.Exceptions.BusinessValidationException("【" + paymentObj.Name + "】计划金额不能大于可付款金额【" + remainValue + "】");
                }
            }
        }
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            if (isNew)
            {
                string engineeringInfo = GetQueryString("EngineeringInfo");
                if (string.IsNullOrEmpty(engineeringInfo))
                {
                    throw new Formula.Exceptions.BusinessValidationException("请选择项目!");
                }

                string sql = string.Format("select * from S_I_Engineering where ID='{0}' ", engineeringInfo);
                var    dt  = EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    throw new Formula.Exceptions.BusinessValidationException("所选项目不存在!");
                }
                var engineering = FormulaHelper.DataRowToDic(dt.Rows[0]);

                dic.SetValue("EngineeringInfo", engineering.GetValue("ID"));
                dic.SetValue("EngineeringInfoName", engineering.GetValue("Name"));
                dic.SetValue("Code", engineering.GetValue("SerialNumber"));

                SerialNumberParam param = new SerialNumberParam()
                {
                    Code            = "TCMWorkingContact",
                    PrjCode         = "",
                    OrgCode         = "",
                    UserCode        = "",
                    CategoryCode    = "",
                    SubCategoryCode = "",
                    OrderNumCode    = ""
                };
                var serialNumber = SerialNumberHelper.GetSerialNumberString("{YY}{MM}{DD}-{NNNN}", param, "YearCode,MonthCode", true);

                dic.SetValue("SerialNumber", serialNumber);
                dic.SetValue("MainCompany", engineering.GetValue("CustomerInfo"));
                dic.SetValue("MainCompanyName", engineering.GetValue("CustomerInfoName"));
                dic.SetValue("SendCompany", CurrentUserInfo.UserOrgID);
                dic.SetValue("SendCompanyName", CurrentUserInfo.UserOrgName);
                dic.SetValue("ID", FormulaHelper.CreateGuid());
            }
        }
Пример #17
0
        public JsonResult SaveAuditFile(string ProductID, string AuditStep, string FileID, bool IsOverride)
        {
            var product = this.GetEntityByID <S_E_Product>(ProductID);

            if (product == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到指定的成果。");
            }
            var PDFAuditFiles = JsonHelper.ToList(product.PDFAuditFiles);

            if (IsOverride)
            {
                PDFAuditFiles.RemoveWhere(a => a.GetValue("AuditStep") == AuditStep && a.GetValue("SubmitUser") == CurrentUserInfo.UserID);
            }

            var dic = new Dictionary <string, object>();

            dic.SetValue("AuditStep", AuditStep);
            dic.SetValue("SubmitUser", CurrentUserInfo.UserID);
            dic.SetValue("SubmitUserName", CurrentUserInfo.UserName);
            dic.SetValue("SubmitDate", System.DateTime.Now.ToString("s"));
            dic.SetValue("Attachment", FileID);
            PDFAuditFiles.Add(dic);

            product.PDFAuditFiles = JsonHelper.ToJson(PDFAuditFiles);
            product.UpdateVersison();
            this.entities.SaveChanges();

            #region 获取PDF中的校审信息
            byte[] bytes = FileStoreHelper.GetFile(FileID);
            var    list  = GetAnnots(bytes);
            #endregion
            var reslut = new Dictionary <string, object>();
            reslut.Add("list", list);
            reslut.Add("code", product.Code);
            return(Json(reslut));
        }
Пример #18
0
 protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
 {
     if (isNew)
     {
         dic.SetValue("ProjectID", GetQueryString("EngineeringInfoID"));
         dic.SetValue("EngineeringInfoID", GetQueryString("EngineeringInfoID"));
         dic.SetValue("CreateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
         dic.SetValue("CreateUser", CurrentUserInfo.UserName);
         dic.SetValue("CreateUserID", CurrentUserInfo.UserID);
         dic.SetValue("CreateUserName", CurrentUserInfo.UserName);
         dic.SetValue("ID", FormulaHelper.CreateGuid());
     }
 }
Пример #19
0
        private Dictionary <string, object> createAngularChart(List <S_W_TaskWork> allTaskWorkList, List <S_W_TaskWork> allFinishTaskWorkList)
        {
            var result   = new Dictionary <string, object>();
            var chartpty = new Dictionary <string, object>();

            chartpty.SetValue("caption", "卷册完成情况分析");
            chartpty.SetValue("bgcolor", "FFFFFF");
            chartpty.SetValue("showBorder", "0");
            chartpty.SetValue("managevalueoverlapping", "1");
            chartpty.SetValue("autoaligntickvalues", "1");
            chartpty.SetValue("fillangle", "45");
            chartpty.SetValue("upperlimit", allTaskWorkList.Count);
            chartpty.SetValue("lowerlimit", 0);
            chartpty.SetValue("showgaugeborder", 0);
            chartpty.SetValue("showvalue", "1");

            var colorrange  = new Dictionary <string, object>();
            var colors      = new List <Dictionary <string, object> >();
            var finishColor = new Dictionary <string, object>();

            finishColor.SetValue("minvalue", 0);
            finishColor.SetValue("maxvalue", allFinishTaskWorkList.Count);
            finishColor.SetValue("code", "8BBA00");
            colors.Add(finishColor);
            var remianColor = new Dictionary <string, object>();

            remianColor.SetValue("minvalue", allFinishTaskWorkList.Count);
            remianColor.SetValue("maxvalue", allTaskWorkList.Count);
            remianColor.SetValue("code", "F6BD0F");
            colors.Add(remianColor);
            colorrange.SetValue("color", colors);
            var dials    = new Dictionary <string, object>();
            var dialList = new List <Dictionary <string, object> >();

            var dial = new Dictionary <string, object>();

            dial.SetValue("value", allFinishTaskWorkList.Count);
            dial.SetValue("borderalpha", "0");
            dial.SetValue("bgcolor", "#000000");
            dial.SetValue("basewidth", "20");
            dial.SetValue("topwidth", "1");
            dial.SetValue("radius", "130");
            dialList.Add(dial);
            dials.SetValue("dial", dialList);
            result.SetValue("dials", dials);
            result.SetValue("chart", chartpty);
            result.SetValue("colorrange", colorrange);
            return(result);
        }
Пример #20
0
        /// <summary>
        /// 修改缺省值
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="value"></param>
        public static void SetDefaultValue(this IPropertyObject obj, Object value, bool throwException)
        {
            PropertyDescriptorCollection pdc = obj.GetPropertyDescriptorCollection();

            if (pdc == null)
            {
                RegisteProperties(obj);
            }
            pdc = obj.GetPropertyDescriptorCollection();
            //没有可以注册的属性
            if (pdc == null)
            {
                if (throwException)
                {
                    throw new Exception("类型" + obj.GetType().Name + "没有可以注册的属性 ");
                }
                else
                {
                    return;
                }
            }
            PropertyDescriptor pd = pdc.GetDefault();

            if (pd == null)
            {
                if (throwException)
                {
                    throw new Exception("类型" + obj.GetType().Name + "没有缺省属性");
                }
                else
                {
                    return;
                }
            }
            int index = pdc.IndexOf(pd);

            if (index < 0)
            {
                return;
            }

            if (!objectPropertiesValues.ContainsKey(obj))
            {
                objectPropertiesValues[obj] = new Dictionary <PropertyDescriptor, object>();
            }
            Dictionary <PropertyDescriptor, object> values = objectPropertiesValues[obj];

            values.SetValue(pd, value);
        }
Пример #21
0
        public override JsonResult GetModel(string id)
        {
            var resourceCode = this.GetQueryString("ResourceCode");
            var resourceName = this.GetQueryString("ResourceName");

            if (String.IsNullOrEmpty(this.GetQueryString("BelongYear")))
            {
                throw new Formula.Exceptions.BusinessValidationException("必须指定年份");
            }
            if (String.IsNullOrEmpty(this.GetQueryString("BelongMonth")))
            {
                throw new Formula.Exceptions.BusinessValidationException("必须指定月份");
            }
            if (String.IsNullOrEmpty(resourceCode))
            {
                throw new Formula.Exceptions.BusinessValidationException("必须指定资源等级");
            }
            var belongYear  = Convert.ToInt32(this.GetQueryString("BelongYear"));
            var belongMonth = Convert.ToInt32(this.GetQueryString("BelongMonth"));
            var entity      = this.entities.Set <S_W_ResourcePrice>().FirstOrDefault(c => c.ResourceCode == resourceCode && c.BelongYear ==
                                                                                     belongYear && c.BelongMonth == belongMonth);

            if (entity == null)
            {
                var date = new DateTime(Convert.ToInt32(belongYear), Convert.ToInt32(belongMonth), 1);
                var dic  = new Dictionary <string, object>();
                dic.SetValue("ResourceCode", resourceCode);
                dic.SetValue("ResourceName", resourceName);
                dic.SetValue("BelongYear", belongYear);
                dic.SetValue("BelongMonth", belongMonth);
                dic.SetValue("StartDate", date);
                var lastEty = this.entities.Set <S_W_ResourcePrice>().Where(c => c.ResourceCode == resourceCode &&
                                                                            c.StartDate <= date).OrderByDescending(c => c.StartDate).FirstOrDefault();
                if (lastEty != null)
                {
                    dic.SetValue("UnitPrice", lastEty.UnitPrice);
                    dic.SetValue("Postion", lastEty.Postion);
                    dic.SetValue("Level", lastEty.Level);
                }
                return(Json(dic));
            }
            else
            {
                return(Json(entity));
            }
        }
Пример #22
0
        public JsonResult GetUserSummaryInfo(QueryBuilder qb)
        {
            var list             = this.entities.Set <S_AE_Mistake>().Where((SearchCondition)qb).ToList();
            var mistakeLevelEnum = EnumBaseHelper.GetEnumDef("Project.MistakeLevel").EnumItem.ToList();
            var userSummaryList  = list.GroupBy(d => new { UserName = d.Designer, UserID = d.DesignerID }).Select(d => new { UserName = d.Key.UserName, UserID = d.Key.UserID, Summary = d.Count() }).ToList().OrderByDescending(d => d.Summary).ToList();
            var result           = new List <Dictionary <string, object> >();

            foreach (var item in userSummaryList)
            {
                var dic = new Dictionary <string, object>();
                dic.SetValue("UserID", item.UserID);
                dic.SetValue("UserName", item.UserName);
                foreach (var mistakeItem in mistakeLevelEnum)
                {
                    var count = list.Count(d => d.DesignerID == item.UserID && d.MistakeLevel == mistakeItem.Code);
                    dic.SetValue(mistakeItem.Code, count);
                }
                dic.SetValue("Summary", item.Summary);
                result.Add(dic);
            }
            var gridData = new GridData(result);

            return(Json(gridData));
        }
Пример #23
0
        /// <summary>
        /// 获取实体类的元设置
        /// </summary>
        public static EntityMeta <T> Get <T>()
        {
            var key = typeof(T).FullName ?? typeof(T).Name;

            if (EntityMetas.TryGetValue(key, out var meta))
            {
                return(meta as EntityMeta <T>);
            }

            //缺少时新增
            var crMeta = new EntityMeta <T>();

            EntityMetas.SetValue(key, crMeta);
            return(crMeta);
        }
Пример #24
0
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            string folderID = this.GetQueryString("FolderID");
            var    folder   = this.GetEntityByID <S_D_Folder>(folderID);

            if (folder == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到指定的目录信息,无法编辑文件");
            }
            if (isNew)
            {
                dic.SetValue("FolderID", folder.ID);
                dic.SetValue("EngineeringInfoID", folder.EngineeringInfoID);
            }
            else
            {
                var ID       = dic.GetValue("ID");
                var attrList = this.EPCEntites.Set <S_D_Document_Attr>().Where(c => c.DocumentID == ID).ToList();
                foreach (var item in attrList)
                {
                    dic.SetValue(item.AttrName, item.AttrValue);
                }
            }
            if (!String.IsNullOrEmpty(folder.AttrDefine))
            {
                ViewBag.HasAttrDefine = true;
                var attrDefine = JsonHelper.ToList(folder.AttrDefine);
                ViewBag.AttrHtml   = folder.GetAttrHTML();
                ViewBag.AttrScript = folder.CreateScript();
            }
            else
            {
                ViewBag.HasAttrDefine = false;
                ViewBag.AttrHtml      = "";
            }
        }
Пример #25
0
        protected override void BeforeSave(Dictionary <string, string> dic, S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                var sql = string.Format(@"select * from S_F_InvestPlan where MakeYear={0} and MakeMonth={1} and ChargerDept='{2}'  order by VersionNumber desc",
                                        dic.GetValue("MakeYear"), dic.GetValue("MakeMonth"), dic.GetValue("ChargerDept"));
                var dt = this.EPCSQLDB.ExecuteDataTable(sql);
                if (dt.Rows.Count == 0)
                {
                    dic.SetValue("VersionNumber", "1");
                }
                else
                {
                    var list = FormulaHelper.DataTableToListDic(dt);
                    //if (list.Exists(d => d.GetValue("FlowPhase") != "End"))
                    //{
                    //    throw new Formula.Exceptions.BusinessValidationException(string.Format("部门【{0}】【{1}年{2}月】有正在审核中的计划编制,无法提交!", dic.GetValue("ChargerDeptName"), dic.GetValue("BelongYear"), dic.GetValue("BelongMonth")));
                    //}

                    var newVersionNumber = Convert.ToInt32(list[0].GetValue("VersionNumber")) + 1;
                    dic.SetValue("VersionNumber", newVersionNumber.ToString());
                }
            }
        }
Пример #26
0
        private List <Dictionary <string, object> > LoadLatestPlan(string chargerDept, int makeYear, int makeMonth, List <Dictionary <string, object> > planMonths)
        {
            var sql = string.Format(@"select * from S_F_EngineeringInvestPlan where ChargerDept='{0}' and MakeYear={1} and MakeMonth={2} ",
                                    chargerDept, makeYear, makeMonth);
            var dt             = this.EPCSQLDB.ExecuteDataTable(sql);
            var InvestPlanList = FormulaHelper.DataTableToListDic(dt);

            var defaultRows = from t in dt.AsEnumerable()
                              group t by new
            {
                EngineeringInfo     = t.Field <string>("EngineeringInfo"),
                EngineeringInfoName = t.Field <string>("EngineeringInfoName"),
                FundType            = t.Field <string>("FundType")
            } into m
            orderby m.Key.EngineeringInfoName ascending, m.Key.FundType descending
                select new
            {
                EngineeringInfo     = m.Key.EngineeringInfo,
                EngineeringInfoName = m.Key.EngineeringInfoName,
                FundType            = m.Key.FundType
            };

            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            foreach (var defaultRow in defaultRows)
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic.SetValue("EngineeringInfo", defaultRow.EngineeringInfo);
                dic.SetValue("EngineeringInfoName", defaultRow.EngineeringInfoName);
                dic.SetValue("FundType", defaultRow.FundType);

                //月份列
                foreach (var planMonth in planMonths)
                {
                    if (InvestPlanList.Count == 0)
                    {
                        dic.SetValue(planMonth.GetValue("ColumnName"), 0m);
                        continue;
                    }
                    var InvestPlan = InvestPlanList.Find(p => p.GetValue("EngineeringInfo") == defaultRow.EngineeringInfo &&
                                                         p.GetValue("FundType") == defaultRow.FundType &&
                                                         p.GetValue("PlanYear") == planMonth.GetValue("Year") &&
                                                         p.GetValue("PlanMonth") == planMonth.GetValue("Month"));
                    if (InvestPlan == null)
                    {
                        dic.SetValue(planMonth.GetValue("ColumnName"), 0m);
                    }
                    else
                    {
                        dic.SetValue(planMonth.GetValue("ColumnName"), InvestPlan.GetValue("Amount"));
                    }
                }
                result.Add(dic);
            }
            return(result);
        }
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            var paymentD = dic.GetValue("ID");

            if (!isNew)
            {
                var contract = this.GetEntityByID <S_P_ContractInfo>(dic.GetValue("ContractInfo"));
                if (contract == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("未能找到指定的合同信息");
                }
                dic.SetValue("ContractValue", contract.ContractAmount);
                var contractPaymentValue = Convert.ToDecimal(contract.S_P_Payment.Where(d => d.ID != paymentD).Sum(d => d.PaymentValue));
                dic.SetValue("ContractPaymentValue", contractPaymentValue);
                var remainPaymentValue = Convert.ToDecimal(contract.ContractAmount) - contractPaymentValue;
                if (remainPaymentValue < 0)
                {
                    remainPaymentValue = 0;
                }
                dic.SetValue("RemainPaymentValue", remainPaymentValue);

                string sql = @"select S_P_Payment_InvoiceRelation.ID,S_P_Invoice.InvoiceCode,
S_P_Invoice.InvoiceValue,S_P_Invoice.InvoiceDate, SumRelationInfo.SumRelateValue,
S_P_Payment_InvoiceRelation.SortIndex
,S_P_Payment_InvoiceRelation.InvoiceID,
S_P_Payment_InvoiceRelation.RelationValue
 from S_P_Payment_InvoiceRelation
left join S_P_Invoice on S_P_Invoice.ID=S_P_Payment_InvoiceRelation.InvoiceID
left join (select Sum(RelationValue) as SumRelateValue,InvoiceID
from S_P_Payment_InvoiceRelation where S_P_PaymentID !='{0}'
group by InvoiceID) SumRelationInfo on  SumRelationInfo.InvoiceID = S_P_Invoice.ID
where S_P_PaymentID='{0}'";
                var    invoiceRelateionDt = this.EPCSQLDB.ExecuteDataTable(String.Format(sql, dic.GetValue("ID")));
                dic.SetValue("InvoiceRelation", JsonHelper.ToJson(invoiceRelateionDt));
            }
        }
Пример #28
0
 private void SetDefualtValue(Dictionary <string, object> result, string attrAttrField, string attrDefaultValue, S_NodeInfo node)
 {
     if (attrDefaultValue.IndexOf("{") >= 0)
     {
         var defaultStr = attrDefaultValue.Replace("{", "").Replace("}", "");
         if (defaultStr == "Now")
         {
             result.SetValue(attrAttrField, DateTime.Now);
         }
         else if (defaultStr == "UserID")
         {
             result.SetValue(attrAttrField, CurrentUserInfo.UserID);
         }
         else if (defaultStr == "UserName")
         {
             result.SetValue(attrAttrField, CurrentUserInfo.UserName);
         }
         else
         {
             var defaultValue = attrDefaultValue.Replace("{", "").Replace("}", "").Split(':');
             var nodePositon  = defaultValue[0];
             var defaultField = defaultValue[1];
             if (nodePositon == "Root")
             {
                 if (node.RootNode.DataEntity.ContainsKey(defaultField))
                 {
                     result.SetValue(attrAttrField, node.RootNode.DataEntity[defaultField]);
                 }
             }
             else if (nodePositon == "Node")
             {
                 if (node.DataEntity.ContainsKey(defaultField))
                 {
                     result.SetValue(attrAttrField, node.DataEntity[defaultField]);
                 }
             }
             else if (nodePositon.Split('.').Length > 0)
             {
                 var pnode = _getParentNode(node, nodePositon.Split('.').Length);
                 if (pnode.DataEntity.ContainsKey(defaultField))
                 {
                     result.SetValue(attrAttrField, node.DataEntity[defaultField]);
                 }
             }
         }
     }
     else
     {
         result.SetValue(attrAttrField, attrDefaultValue);
     }
 }
Пример #29
0
        protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID)
        {
            var receiptID = dic.GetValue("ID");

            if (!isNew)
            {
                var contract = this.GetEntityByID <S_M_ContractInfo>(dic.GetValue("ContractInfo"));
                if (contract == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("未能找到指定的合同信息");
                }
                dic.SetValue("ContractValue", contract.ContractRMBValue);
                var contractReceiptValue = Convert.ToDecimal(contract.S_M_Receipt.Where(d => d.ID != receiptID).Sum(d => d.ReceiptValue));
                dic.SetValue("ContractReceiptValue", contractReceiptValue);
                var remainReceiptValue = Convert.ToDecimal(contract.ContractRMBValue) - contractReceiptValue;
                if (remainReceiptValue < 0)
                {
                    remainReceiptValue = 0;
                }
                dic.SetValue("RemainReceiptValue", remainReceiptValue);

                string sql = @"select S_M_Receipt_InvoiceRelation.ID,
S_M_Invoice.InvoiceValue,S_M_Invoice.InvoiceDate, SumRelationInfo.SumRelateValue,
S_M_Receipt_InvoiceRelation.SortIndex
,S_M_Receipt_InvoiceRelation.InvoiceID,
S_M_Receipt_InvoiceRelation.RelationValue
 from S_M_Receipt_InvoiceRelation
left join S_M_Invoice on S_M_Invoice.ID=S_M_Receipt_InvoiceRelation.InvoiceID
left join (select Sum(RelationValue) as SumRelateValue,InvoiceID
from S_M_Receipt_InvoiceRelation where S_M_ReceiptID !='{0}'
group by InvoiceID) SumRelationInfo on  SumRelationInfo.InvoiceID = S_M_Invoice.ID
where S_M_ReceiptID='{0}' ";
                var    invoiceRelateionDt = this.EPCSQLDB.ExecuteDataTable(String.Format(sql, dic.GetValue("ID")));
                dic.SetValue("InvoiceRelation", JsonHelper.ToJson(invoiceRelateionDt));
            }

            var register = this.GetEntityByID <S_M_ReceiptRegister>(dic.GetValue("RegisterID"));

            if (register != null)
            {
                dic.SetValue("ReceiptRegisterValue", register.ReceiptValue);
                var confirmValue = 0m;
                if (this.EPCEntites.Set <S_M_Receipt>().Count(d => d.ID != receiptID && d.RegisterID == register.ID) > 0)
                {
                    confirmValue = Convert.ToDecimal(this.EPCEntites.Set <S_M_Receipt>().Where(d => d.ID != receiptID && d.RegisterID == register.ID).Sum(d => d.ReceiptValue));
                }
                dic.SetValue("ConfirmValue", confirmValue);
                var remainValue = Convert.ToDecimal(register.ReceiptValue) - confirmValue;
                dic.SetValue("RemainValue", remainValue);
            }
        }
Пример #30
0
        public void Push()
        {
            var nodeDic = this.GetDataDicByID("S_EP_CBSNode", this.ModelDic.GetValue("CBSNode"));

            if (nodeDic == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到对应的CBS节点,无法调整产值");
            }
            Expenses.Logic.CBSInfoFO.SynCBSInfo(this.ModelDic, SetCBSOpportunity.ProductionSplit);
            #region 记录CBS变更记录
            var subsidyInfo = new Dictionary <string, object>();
            subsidyInfo.SetValue("UseType", ProductionChangeType.ReSplit.ToString());
            subsidyInfo.SetValue("UseCBSNode", nodeDic.GetValue("ID"));
            subsidyInfo.SetValue("UseCBSInfo", nodeDic.GetValue("CBSInfoID"));
            subsidyInfo.SetValue("UseValue", 0);
            subsidyInfo.SetValue("OperationUser", this.ModelDic.GetValue("CreateUserID"));
            subsidyInfo.SetValue("OperationUserName", this.ModelDic.GetValue("CreateUser"));
            subsidyInfo.SetValue("UseDate", DateTime.Now);
            subsidyInfo.SetValue("UseReason", this.ModelDic.GetValue("Reason"));
            subsidyInfo.SetValue("ApplyFormID", this.ModelDic.GetValue("ID"));
            subsidyInfo.SetValue("ApplyFormCode", "ProductionDistribute");
            subsidyInfo.InsertDB(this.DB, "S_EP_ProductionCBSChangeLog");
            #endregion
        }
        protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew)
        {
            if (isNew)
            {
                dic.SetValue("State", InvoiceApplyState.New.ToString());
            }
            var entity = this.GetEntityByID(dic["ID"]);

            if (entity == null)
            {
                entity = new T_C_CreditNoteApply();
            }
            this.UpdateEntity(entity, dic);
            entity.Validate();
        }
Пример #32
0
    public static IDictionary<string, string> ParseAuthorizationHeader(string header) {
      while (header.StartsWith("OAuth")) header = header.Substring(5).Trim();

      var result = new Dictionary<string, string>();
      while (header.Length > 0) {
        var eq = header.IndexOf('=');
        if (eq < 0) eq = header.Length;
        var name = header.Substring(0, eq).Trim().Trim(',').Trim();

        var value = header = header.Substring((eq + 1).AtMost(header.Length)).Trim();

        if (value.StartsWith("\"")) {
          ProcessHeaderValue(1, ref header, ref value, '"');
        } else if (value.StartsWith("'")) {
          ProcessHeaderValue(1, ref header, ref value, '\'');
        } else {
          ProcessHeaderValue(0, ref header, ref value, ' ', ',');
        }

        result.SetValue(name, Uri.UnescapeDataString(value));
      }

      return result;
    }
Пример #33
0
        /// <summary>
        /// Searches for shortest path in the graph. Uses Dijkstra 1-1 form (A*).
        /// </summary>
        /// <param name="from">Source vertex</param>
        /// <param name="to">Target vertex</param>
        /// <param name="keepInTheSameQuarter">Indicator whether the searching has to use only vertices from the same quarter as the from position is in</param>
        /// <returns>Set of vertices forming result path</returns>
        public static IEnumerable<PathGraphVertex> FindShortestPath(PathGraphVertex from, PathGraphVertex to, bool keepInTheSameQuarter)
        {
            keepInTheSameQuarter = keepInTheSameQuarter && from.Position.Quarter == to.Position.Quarter;
            TownQuarter fromQuarter = from.Position.Quarter;

            LinkedList<PathGraphVertex> resultPath = new LinkedList<PathGraphVertex>();
            HashSet<PathGraphVertex> closed = new HashSet<PathGraphVertex>();
            Dictionary<PathGraphVertex, PathGraphVertex> cameFrom = new Dictionary<PathGraphVertex, PathGraphVertex>();
            Dictionary<PathGraphVertex, float> gScore = new Dictionary<PathGraphVertex, float>();
            gScore.Add(from, 0);
            Dictionary<PathGraphVertex, float> fScore = new Dictionary<PathGraphVertex, float>();
            fScore.Add(from, gScore[from] + HeuristicDistance(from, to));
            HashSet<PathGraphVertex> open = new HashSet<PathGraphVertex>();
            open.Add( from);

            while (open.Count != 0)
            {
                float lowestScore = float.MaxValue;
                PathGraphVertex lowestVertex = null;
                foreach (PathGraphVertex openedOne in open)
                {
                    float score = fScore[openedOne];
                    if (score < lowestScore)
                    {
                        lowestVertex = openedOne;
                    }
                }
                PathGraphVertex current = lowestVertex;//open.OrderBy(x => fScore[x]).First();
                if (current == to)
                {
                    PathGraphVertex t = to;
                    while(t != from)
                    {
                        resultPath.AddFirst(t);
                        t = cameFrom[t];
                    }
                    resultPath.AddFirst(from);
                    return resultPath;
                }
                open.Remove(current);

                closed.Add(current);
                foreach (PathGraphVertex n in current.Neighbors)
                {
                    if (closed.Contains(n) || (keepInTheSameQuarter && n.Position.Quarter != fromQuarter))
                    {
                        continue;
                    }
                    else
                    {
                        float tempGSore = gScore[current] + current.GetDistanceToNeighbor(n);
                        if (!open.Contains(n) || tempGSore <= gScore[n])
                        {
                            cameFrom.SetValue(n, current);
                            gScore.SetValue(n, tempGSore);
                            fScore.SetValue(n, gScore[n] + HeuristicDistance(current, n));
                            if (!open.Contains(n))
                            {
                                open.Add(n);
                            }
                        }
                    }
                }
            }

            throw new PathNotFoundException("Source and target vertices aren't in the same component.");
        }
Пример #34
0
		public void Extensions_SetValue_Dictionary_Works() {
			var dict = new Dictionary<int, int>();
			dict.SetValue(23, 456);
			Assert.AreEqual(456, dict[23]);
		}