Пример #1
0
        internal void InitFileServerInfo(TransferInfo transferInfo)
        {
            HostName = transferInfo.FileServerInfo.HostName;
            if (string.IsNullOrEmpty(HostName))
            {
                throw new ApplicationException(FileServerIsNotSetting);
            }

            string localname = Dns.GetHostName();

            _isLocalMachine = (HostName.ToLower() == localname.ToLower());

            VirtualDirectory = transferInfo.FileServerInfo.VirtualDirectory;
            FileDirectory    = transferInfo.FileServerInfo.FileDirectory;
            FileDirectory    = string.IsNullOrEmpty(FileDirectory) ? "Accessories" : FileDirectory;
            ProtocolType     = transferInfo.FileServerInfo.Connect;
            UploadPostUrl    = transferInfo.FileServerInfo.UploadPostUrl;
            HostPort         = int.Parse(transferInfo.FileServerInfo.Port);
            if (HostPort <= 0)
            {
                switch (ProtocolType.ToUpper())
                {
                case "HTTP":
                    HostPort = 80;
                    break;

                case "FTP":
                    HostPort = 21;
                    break;
                }
                HostUrl = ProtocolType + @"://" + HostName;
            }
            else
            {
                HostUrl = ProtocolType + @"://" + HostName + ":" + HostPort;
            }

            ProtocolType = transferInfo.FileServerInfo.Connect;

            bool isUseProxy = TypeConvert.ToBool(transferInfo.FileServerProxy.IsUsed, false);

            _supportDebug        = TypeConvert.ToBool(transferInfo.FileServerInfo.SupportDebug, true);
            _supportBorkenResume = TypeConvert.ToBool(transferInfo.FileServerInfo.SupportBrokenResume, true);

            if (isUseProxy)
            {
                if (_environment == null)
                {
                    _environment = new WebEnvironment();
                }

                _environment.UseProxy = true;
                _environment.ProxyUrl = transferInfo.FileServerProxy.UriAddress;
                int proxyPort = Int32.Parse(transferInfo.FileServerProxy.Port);
                if (proxyPort != 80 && proxyPort != 21)
                {
                    _environment.ProxyUrl += ":" + proxyPort;
                }
            }

            bool isUserAuth = TypeConvert.ToBool(transferInfo.FileServerAuth.IsUsed, false);

            if (isUserAuth)
            {
                if (_environment == null)
                {
                    _environment = new WebEnvironment();
                }
                if (isUseProxy)
                {
                    _environment.ProxyUsername = transferInfo.FileServerAuth.UserName;
                    _environment.ProxyPassword = transferInfo.FileServerAuth.Password;
                }
                else
                {
                    _environment.Username = transferInfo.FileServerAuth.UserName;
                    _environment.Password = transferInfo.FileServerAuth.Password;
                }
            }
        }
Пример #2
0
        public void ToEnumTest2()
        {
            var e = TypeConvert.ToEnum <SomeEnum>(2);

            Assert.AreEqual(SomeEnum.B, e);
        }
Пример #3
0
        public T GetPropertyValue <T>(int propType)
        {
            string textValue = GetPropertyValue(propType);

            return(TypeConvert.ChangeType <T>(textValue));
        }
Пример #4
0
        /// 静态函数
        ///
        private static List <PointF> ComputeDefaultROIPoints(ushort[,] imgData)
        {
            ushort[,] imagedataTemp = (ushort[, ])imgData.Clone();
            int[] rdata    = LunImage.FindMaxAndMin(imagedataTemp);
            int   maxValue = rdata[0];
            int   minValue = rdata[1];
            int   lenValue = maxValue - minValue + 1;

            int[] histogramData = new int[lenValue];
            foreach (int da in imgData)
            {
                histogramData[da - minValue]++;
            }

            double sum            = 0;
            double csum           = 0.0;
            int    n              = 0;
            int    thresholdValue = 0;

            for (int k = 0; k < lenValue; k++)
            {
                sum += (double)k * (double)histogramData[k];    /* x*f(x) 质量矩*/
                n   += histogramData[k];                        /*  f(x)    质量    */
            }

            if (n <= 0)
            {
                // if n has no value, there is problems...
                return(new List <PointF>());
            }
            // do the otsu global thresholding method
            double fmax = -1.0;
            int    n1 = 0;
            int    n2 = 0;
            double m1, m2 = 0;

            for (int k = 0; k < lenValue; k++)
            {
                n1 += histogramData[k];
                if (n1 <= 0)
                {
                    continue;
                }
                n2 = n - n1;
                if (n2 == 0)
                {
                    break;
                }
                csum += (double)k * histogramData[k];
                m1    = csum / n1;
                m2    = (sum - csum) / n2;
                double sb = (double)n1 * (double)n2 * (m1 - m2) * (m1 - m2);
                /* bbg: note: can be optimized. */
                if (sb > fmax)
                {
                    fmax           = sb;
                    thresholdValue = k;
                }
            }
            for (int i = 0; i < imagedataTemp.GetLength(0); i++)
            {
                for (int j = 0; j < imagedataTemp.GetLength(1); j++)
                {
                    if (imagedataTemp[i, j] < thresholdValue)
                    {
                        imagedataTemp[i, j] = 0;
                    }
                    else
                    {
                        imagedataTemp[i, j] = (ushort)thresholdValue;
                    }
                }
            }

            int level  = thresholdValue / 2;
            int window = thresholdValue / 5;

            Histogram his   = new Histogram(imagedataTemp);
            int       HFMax = level + window / 2;
            int       HFMin = level - window / 2;

            if (HFMax < 0 || HFMin < 0)
            {
                level  = his.WinCenter;
                window = his.WinWidth;
            }
            else
            {
                if (HFMax > his.MaxValue || HFMin > his.MaxValue)
                {
                    level  = his.WinCenter;
                    window = his.WinWidth;
                }
            }
            int maxvalue = his.LenValue < 256 ? 256 : his.LenValue;

            maxValue = maxvalue;
            minValue = his.MinValue;
            Color[] LUT = HisLUT.RefreshLUT(null, false, level, window, maxvalue, minValue);
            Bitmap  BMP = TypeConvert.SliceImageToBitmap24(imagedataTemp, LUT, minValue);

            float           x1 = 0;
            float           y1 = 0;
            float           x2 = BMP.Width - 1;
            float           y2 = BMP.Height - 1;
            BoundaryTracker bt = new BoundaryTracker();

            bt.GetSerializedBoundary(BMP, LUT[0], new Rectangle((int)x1, (int)y1, (int)(x2 - x1 + 1), (int)(y2 - y1 + 1)), false);
            List <PointF> temp = new List <PointF>();

            if (bt.MaxPointIdx != -1)
            {
                PointF[] tmp = bt.CL[bt.MaxPointIdx];
                if (tmp.Length > 3)
                {
                    for (int i = 0; i < tmp.Length; i++)
                    {
                        temp.Add(tmp[i]);
                    }
                }
            }
            else
            {
                temp.Add(new PointF(0, 0));
                temp.Add(new PointF(0, BMP.Height - 1));
                temp.Add(new PointF(BMP.Width - 1, BMP.Height - 1));
                temp.Add(new PointF(BMP.Width - 1, 0));
            }
            return(temp);
        }
Пример #5
0
        public override BaseResult Add(dynamic entity)
        {
            BaseResult  br          = new BaseResult();
            Hashtable   param       = (Hashtable)entity;
            Tb_Cgs_Edit model       = (Tb_Cgs_Edit)param["model"];
            long        id_supplier = TypeConvert.ToInt64(param["id_supplier"], 0);
            string      flag_from   = param.ContainsKey("flag_from") ? param["flag_from"].ToString() : "PC";

            if (model == null || !model.id.HasValue || !(model.id > 0) || id_supplier.Equals(0))
            {
                br.Success = false;
                br.Message.Add("关注参数错误.");
                br.Level = ErrorLevel.Warning;
                br.Data  = "companyName";
                return(br);
            }


            Hashtable ht = new Hashtable();

            ht.Add("id_gys", id_supplier);
            ht.Add("id_cgs", model.id);
            var gcgx = DAL.GetItem <Tb_Gys_Cgs_Check>(typeof(Tb_Gys_Cgs_Check), ht);

            if (gcgx == null)
            {
                br.Success = false;
                br.Message.Add("客户的申请已处理过了.");
                br.Level = ErrorLevel.Warning;
                return(br);
            }
            if (gcgx.flag_form.Equals(Gys_Cgs_Status.Refuse))
            {
                br.Success = false;
                br.Message.Add("客户的申请已被拒绝过了.");
                br.Level = ErrorLevel.Warning;
                return(br);
            }

            //采购商
            param.Clear();
            param["id"] = model.id;
            var cgs = (Tb_Cgs)DAL.GetItem <Tb_Cgs>(typeof(Tb_Cgs), param);

            if (cgs == null || !cgs.id.HasValue || !(cgs.id > 0))
            {
                //成功后删除申请记录
                DAL.Delete(typeof(Tb_Gys_Cgs_Check), ht);
                br.Success = false;
                br.Message.Add("客户不存在.");
                br.Level = ErrorLevel.Warning;
                br.Data  = "cgs";
                return(br);
            }
            param.Clear();
            param["id"] = id_supplier;
            var gys = (Tb_Gys)DAL.GetItem <Tb_Gys>(typeof(Tb_Gys), param);

            if (gys == null || !gys.id.HasValue || !(gys.id > 0))
            {
                //成功后删除申请记录
                DAL.Delete(typeof(Tb_Gys_Cgs_Check), ht);
                br.Success = false;
                br.Message.Add("供应商不存在.");
                br.Level = ErrorLevel.Warning;
                br.Data  = "gys";
                return(br);
            }

            string name_gys = gys.companyname;

            param.Clear();
            param.Add("alias_cgs", model.companyname);
            param.Add("id_user_master_gys", gys.id_user_master);
            param.Add("not_id_user_master_cgs", cgs.id_user_master);
            if (DAL.GetCount(typeof(Tb_Gys_Cgs), param) > 0)
            {
                br.Success = false;
                br.Message.Add("客户名已被使用");
                br.Level = ErrorLevel.Warning;
                br.Data  = "companyName";
                return(br);
            }
            if (!model.bm_gys_Interface.IsEmpty())
            {
                param.Clear();
                param.Add("bm_gys_Interface", model.bm_gys_Interface);
                param.Add("id_user_master_gys", gys.id_user_master);
                param.Add("not_id_user_master_cgs", cgs.id_user_master);
                if (DAL.GetCount(typeof(Tb_Gys_Cgs), param) > 0)
                {
                    br.Success = false;
                    br.Message.Add("客户编码已被使用");
                    br.Level = ErrorLevel.Warning;
                    br.Data  = "bm_gys_Interface";
                    return(br);
                }
            }

            //获取供应商的公司名称
            param.Clear();
            param.Add("id", gys.id_user_master);
            var    TbUser          = DAL.GetItem <Tb_User>(typeof(Tb_User), param);
            string gys_companyname = string.Empty;

            if (TbUser != null)
            {
                gys_companyname = TbUser.companyname;
            }


            param.Clear();
            param["id_user_master_gys"] = gys.id_user_master;
            param["id_user_master_cgs"] = cgs.id_user_master;
            if (DAL.GetCount(typeof(Tb_Gys_Cgs), param) > 0)
            {
                if (gys_companyname != string.Empty)
                {
                    param.Add("new_alias_gys", gys_companyname);
                }
                param.Add("new_alias_cgs", model.companyname);
                param.Add("new_id_cgs_level", model.id_cgs_level);
                param.Add("new_bm_gys_Interface", model.bm_gys_Interface);
                param.Add("new_rq_treaty_end", model.rq_treaty_end);
                param.Add("new_rq_treaty_start", model.rq_treaty_start);
                param.Add("new_flag_stop", YesNoFlag.No);
                param.Add("new_rq_edit", model.rq_edit);
                param.Add("new_id_edit", model.id_edit);
                DAL.UpdatePart(typeof(Tb_Gys_Cgs), param);
            }
            else
            {
                Tb_Gys_Cgs gysCgs = new Tb_Gys_Cgs();
                gysCgs.id_gys             = id_supplier;
                gysCgs.id_cgs             = cgs.id;
                gysCgs.alias_cgs          = model.companyname;
                gysCgs.alias_gys          = name_gys;
                gysCgs.flag_from          = flag_from;
                gysCgs.flag_pay           = model.flag_pay;
                gysCgs.flag_stop          = YesNoFlag.No;
                gysCgs.id_cgs_level       = model.id_cgs_level;
                gysCgs.id_create          = model.id_create;
                gysCgs.id_edit            = model.id_edit;
                gysCgs.id_user_cgs        = cgs.id_user_master;
                gysCgs.id_user_gys        = gys.id_user_master;
                gysCgs.id_user_master_cgs = cgs.id_user_master;
                gysCgs.id_user_master_gys = gys.id_user_master;
                gysCgs.rq_treaty_end      = model.rq_treaty_end;
                gysCgs.rq_treaty_start    = model.rq_treaty_start;
                gysCgs.bm_gys_Interface   = model.bm_gys_Interface;
                gysCgs.rq_create          = DateTime.Now;
                DAL.Add(gysCgs);
            }

            //成功后删除申请记录
            DAL.Delete(typeof(Tb_Gys_Cgs_Check), ht);

            //记录供采关系日志
            var Loggcgx = new Tb_Gys_Cgs_Log();

            Loggcgx.id_cgs     = cgs.id.Value;
            Loggcgx.id_gys     = gys.id.Value;
            Loggcgx.id_user    = model.id_create.Value;
            Loggcgx.flag_state = Gys_Cgs_Status.Accept;
            Loggcgx.flag_form  = flag_from;
            Loggcgx.contents   = string.Format("[{0}]接受[{1}]成为客户.", gys.companyname, cgs.companyname);
            DAL.Add(Loggcgx);

            br.Message.Add(string.Format("[{0}]接受[{1}]成为客户.", gys.companyname, cgs.companyname));
            br.Success = true;
            return(br);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE));
            Visible = (Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!Visible)
            {
                return;
            }
            gID = CommonTypeConvert.ToGuid(Request["ID"]);
            if (!IsPostBack)
            {
                Guid gDuplicateID = CommonTypeConvert.ToGuid(Request["DuplicateID"]);
                if (!CommonTypeConvert.IsEmptyGuid(gID) || !CommonTypeConvert.IsEmptyGuid(gDuplicateID))
                {
                    var    oQuery   = new InlineQueryDBManager();
                    string innerSql = ApplicationSQL.SQL["Products_EditView"].ToString();
                    oQuery.CommandText = innerSql;
                    CRMSecurity.Filter(oQuery, m_sMODULE, "edit");
                    if (!CommonTypeConvert.IsEmptyGuid(gDuplicateID))
                    {
                        TypeConvert.AppendParameter(oQuery, gDuplicateID, "ID", false);
                        gID = Guid.Empty;
                    }
                    else
                    {
                        TypeConvert.AppendParameter(oQuery, gID, "ID", false);
                    }

                    using (SqlDataReader rdr = oQuery.ExecuteReader(CommandBehavior.SingleRow))
                    {
                        if (rdr.Read())
                        {
                            ctlModuleHeader.Title = CommonTypeConvert.ToString(rdr["NAME"]);
                            SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " +
                                         ctlModuleHeader.Title);
                            Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                            ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                            AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                            AppendEditViewFields(m_sMODULE + ".CostView", tblCost, rdr);
                            AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, rdr);
                            ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView",
                                                            CommonTypeConvert.ToGuid(rdr["ASSIGNED_USER_ID"]), rdr);
                            var txtNAME = FindControl("NAME") as TextBox;
                            if (txtNAME != null)
                            {
                                txtNAME.ReadOnly = false;
                            }
                        }
                        else
                        {
                            ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null);
                            ctlDynamicButtons.DisableAll();
                            ctlDynamicButtons.ErrorText = Translation.GetTranslation.Term("ACL.LBL_NO_ACCESS");
                        }
                    }
                }
                else
                {
                    AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                    AppendEditViewFields(m_sMODULE + ".CostView", tblCost, null);
                    AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, null);
                    ctlDynamicButtons.AppendButtons(m_sMODULE + ".EditView", Guid.Empty, null);
                    var txtNAME = FindControl("NAME") as TextBox;
                    if (txtNAME != null)
                    {
                        txtNAME.ReadOnly = false;
                    }
                    Guid gPARENT_ID = CommonTypeConvert.ToGuid(Request["PARENT_ID"]);
                    if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID))
                    {
                        string sMODULE      = String.Empty;
                        string sPARENT_TYPE = String.Empty;
                        string sPARENT_NAME = String.Empty;
                        CommonProcedure.ParentGet(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
                        if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts")
                        {
                            new DynamicControl(this, "ACCOUNT_ID").ID     = gPARENT_ID;
                            new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME;
                        }
                        else if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts")
                        {
                            new DynamicControl(this, "CONTACT_ID").ID     = gPARENT_ID;
                            new DynamicControl(this, "CONTACT_NAME").Text = sPARENT_NAME;
                        }
                    }
                }
            }
            else
            {
                ctlModuleHeader.Title = CommonTypeConvert.ToString(ViewState["ctlModuleHeader.Title"]);
                SetPageTitle(Translation.GetTranslation.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
            }
        }
        public ActionResult saveProgEval(FormCollection saveForm)
        {
            InvokeResult result = new InvokeResult();

            #region 构建数据
            string        tbName        = PageReq.GetForm("tbName");
            string        queryStr      = PageReq.GetForm("queryStr");
            string        dataStr       = PageReq.GetForm("dataStr");
            int           saveStatus    = PageReq.GetFormInt("saveStatus");//0:保存  1:提交
            List <string> filterStrList = new List <string>()
            {
                "tbName", "queryStr", "actionUserStr", "flowId", "stepIds",
                "fileTypeId", "fileObjId", "tableName", "keyName", "keyValue", "delFileRelIds", "uploadFileList", "fileSaveType", "skipStepIds"
            };
            BsonDocument dataBson = new BsonDocument();
            var          allKeys  = saveForm.AllKeys.Where(i => !filterStrList.Contains(i));
            if (dataStr.Trim() == "")
            {
                foreach (var tempKey in allKeys)
                {
                    if (tempKey == "tbName" || tempKey == "queryStr" || tempKey.Contains("fileList[") || tempKey.Contains("param."))
                    {
                        continue;
                    }

                    dataBson.Add(tempKey, PageReq.GetForm(tempKey));
                }
            }
            else
            {
                dataBson = TypeConvert.ParamStrToBsonDocument(dataStr);
            }
            #endregion

            #region 验证参数

            string       flowId  = PageReq.GetForm("flowId");
            BsonDocument flowObj = dataOp.FindOneByQuery("BusFlow", Query.EQ("flowId", flowId));
            if (flowObj.IsNullOrEmpty())
            {
                result.Message = "无效的流程模板";
                result.Status  = Status.Failed;
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }

            var          stepList = dataOp.FindAllByKeyVal("BusFlowStep", "flowId", flowId).OrderBy(c => c.Int("stepOrder")).ToList();
            BsonDocument bootStep = stepList.Where(c => c.Int("actTypeId") == (int)FlowActionType.Launch).FirstOrDefault();
            if (saveStatus == 1 && bootStep.IsNullOrEmpty())//提交时才判断
            {
                result.Message = "该流程缺少发起步骤";
                result.Status  = Status.Failed;
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var        activeStepIdList     = PageReq.GetFormIntList("stepIds");
            List <int> hitEnslavedStepOrder = dataOp.FindAllByKeyVal("BusFlowStep", "enslavedStepId", bootStep.Text("stepId")).OrderBy(c => c.Int("stepOrder")).Select(c => c.Int("stepOrder")).Distinct().ToList();
            List <int> hitStepIds           = stepList.Where(c => hitEnslavedStepOrder.Contains(c.Int("stepOrder"))).Select(c => c.Int("stepId")).ToList();
            if (saveStatus == 1 && activeStepIdList.Count() <= 0 && hitEnslavedStepOrder.Count() > 0)//提交时才判断
            {
                result.Status  = Status.Failed;
                result.Message = "请先选定会签部门";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            TableRule rule = new TableRule(tbName);

            ColumnRule columnRule = rule.ColumnRules.Where(t => t.IsPrimary == true).FirstOrDefault();
            string     keyName    = columnRule != null ? columnRule.Name : "";

            #region 验证重名
            string       newName   = PageReq.GetForm("name").Trim();
            BsonDocument curChange = dataOp.FindOneByQuery(tbName, TypeConvert.NativeQueryToQuery(queryStr));
            BsonDocument oldChange = dataOp.FindOneByQuery(tbName, Query.EQ("name", newName));
            if (!oldChange.IsNullOrEmpty() && oldChange.Int(keyName) != curChange.Int(keyName))
            {
                result.Message = "已经存在该名称的方案评审";
                result.Status  = Status.Failed;
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            #region 保存数据
            result = dataOp.Save(tbName, queryStr != "" ? TypeConvert.NativeQueryToQuery(queryStr) : Query.Null, dataBson);
            if (result.Status == Status.Failed)
            {
                result.Message = "保存方案评审失败";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            #region 文件上传
            int primaryKey = 0;

            if (!string.IsNullOrEmpty(queryStr))
            {
                var query     = TypeConvert.NativeQueryToQuery(queryStr);
                var recordDoc = dataOp.FindOneByQuery(tbName, query);
                saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                if (recordDoc != null)
                {
                    primaryKey = recordDoc.Int(keyName);
                }
            }

            if (primaryKey == 0)//新建
            {
                if (saveForm["tableName"] != null)
                {
                    saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                }
            }
            else//编辑
            {
                #region  除文件
                string delFileRelIds = saveForm["delFileRelIds"] != null ? saveForm["delFileRelIds"] : "";
                if (!string.IsNullOrEmpty(delFileRelIds))
                {
                    FileOperationHelper opHelper = new FileOperationHelper();
                    try
                    {
                        string[] fileArray;
                        if (delFileRelIds.Length > 0)
                        {
                            fileArray = delFileRelIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            if (fileArray.Length > 0)
                            {
                                foreach (var item in fileArray)
                                {
                                    var result1 = opHelper.DeleteFileByRelId(int.Parse(item));
                                    if (result1.Status == Status.Failed)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Status  = Status.Failed;
                        result.Message = ex.Message;
                        return(Json(TypeConvert.InvokeResultToPageJson(result)));
                    }
                }
                #endregion

                saveForm["keyValue"] = primaryKey.ToString();
            }
            result.FileInfo = SaveMultipleUploadFiles(saveForm);
            #endregion

            #region 保存审批人员
            InvokeResult tempResult = new InvokeResult();

            int          proEvalId  = result.BsonInfo.Int(keyName);
            BsonDocument proEvalObj = result.BsonInfo;
            PageJson     json       = new PageJson();
            json.AddInfo("proEvalId", proEvalId.ToString());

            var actionUserStr = PageReq.GetForm("actionUserStr");

            #region 查找方案评审流程模板关联,没有则添加
            BsonDocument proEvalFlowRel = dataOp.FindOneByQuery("ProgrammeEvaluationBusFlow", Query.EQ("proEvalId", proEvalId.ToString()));
            if (proEvalFlowRel.IsNullOrEmpty())
            {
                tempResult = dataOp.Insert("ProgrammeEvaluationBusFlow", "proEvalId=" + proEvalId.ToString() + "&flowId=" + flowId);
                if (tempResult.Status == Status.Failed)
                {
                    json.Success = false;
                    json.Message = "插入流程关联失败";
                    return(Json(json));
                }
                else
                {
                    proEvalFlowRel = tempResult.BsonInfo;
                }
            }
            #endregion

            #region 初始化流程实例
            var helper         = new Yinhe.ProcessingCenter.BusinessFlow.FlowInstanceHelper(dataOp);
            var flowUserHelper = new Yinhe.ProcessingCenter.BusinessFlow.FlowUserHelper(dataOp);

            //当前步骤
            BsonDocument curStep             = null;
            var          hasOperateRight     = false;        //是否可以跳转步骤
            var          hasEditRight        = false;        //是否可以编辑表单
            var          canForceComplete    = false;        //是否可以强制结束当前步骤
            string       curAvaiableUserName = string.Empty; //当前可执行人
            BsonDocument curFlowInstance     = dataOp.FindAllByQuery("BusFlowInstance",
                                                                     Query.And(
                                                                         Query.EQ("tableName", "ProgrammeEvaluation"),
                                                                         Query.EQ("referFieldName", "proEvalId"),
                                                                         Query.EQ("referFieldValue", proEvalId.ToString())
                                                                         )
                                                                     ).OrderByDescending(i => i.Date("createDate")).FirstOrDefault();
            if (curFlowInstance.IsNullOrEmpty() == false)
            {
                //初始化流程状态
                curStep = helper.InitialExecuteCondition(flowObj.Text("flowId"), curFlowInstance.Text("flowInstanceId"), dataOp.GetCurrentUserId(), ref hasOperateRight, ref hasEditRight, ref canForceComplete, ref curAvaiableUserName);
                if (curStep == null)
                {
                    curStep = curFlowInstance.SourceBson("stepId");
                }
            }
            else
            {
                curStep = bootStep;
                //初始化流程实例
                if (flowObj != null && curStep != null)
                {
                    curFlowInstance = new BsonDocument();
                    curFlowInstance.Add("flowId", flowObj.Text("flowId"));
                    curFlowInstance.Add("stepId", curStep.Text("stepId"));
                    curFlowInstance.Add("tableName", "ProgrammeEvaluation");
                    curFlowInstance.Add("referFieldName", "proEvalId");
                    curFlowInstance.Add("referFieldValue", proEvalId);
                    curFlowInstance.Add("instanceStatus", "0");
                    curFlowInstance.Add("instanceName", proEvalObj.Text("name"));
                    tempResult = helper.CreateInstance(curFlowInstance);
                    if (tempResult.Status == Status.Successful)
                    {
                        curFlowInstance = tempResult.BsonInfo;
                    }
                    else
                    {
                        json.Success = false;
                        json.Message = "创建流程实例失败:" + tempResult.Message;
                        return(Json(json));
                    }
                    helper.InitialExecuteCondition(flowObj.Text("flowId"), curFlowInstance.Text("flowInstanceId"), dataOp.GetCurrentUserId(), ref hasOperateRight, ref hasEditRight, ref canForceComplete, ref curAvaiableUserName);
                }
                if (curStep == null)
                {
                    curStep = stepList.FirstOrDefault();
                }
            }
            #endregion

            #region 保存流程实例步骤人员

            List <BsonDocument> allStepList = dataOp.FindAllByKeyVal("BusFlowStep", "flowId", flowId).ToList();  //所有步骤

            //获取可控制的会签步骤
            string curStepId = curStep.Text("stepId");

            var oldRelList = dataOp.FindAllByKeyVal("InstanceActionUser", "flowInstanceId", curFlowInstance.Text("flowInstanceId")).ToList();  //所有的审批人
            //stepId + "|Y|" + uid +"|N|"+ status + "|H|";
            var arrActionUserStrUserStr = actionUserStr.Split(new string[] { "|H|" }, StringSplitOptions.RemoveEmptyEntries);
            var storageList             = new List <StorageData>();
            //不需要审批的所有步骤的id--袁辉
            var skipStepIds = PageReq.GetForm("skipStepIds");
            var flowHelper  = new FlowInstanceHelper();
            foreach (var userStr in arrActionUserStrUserStr)
            {
                var arrUserStatusStr = userStr.Split(new string[] { "|N|" }, StringSplitOptions.None);
                if (arrUserStatusStr.Length <= 1)
                {
                    continue;
                }
                string status     = arrUserStatusStr[1];//该流程步骤人员是否有效 0:有效 1:无效
                var    arrUserStr = arrUserStatusStr[0].Split(new string[] { "|Y|" }, StringSplitOptions.RemoveEmptyEntries);
                var    stepId     = int.Parse(arrUserStr[0]);
                var    curStepObj = allStepList.Where(c => c.Int("stepId") == stepId).FirstOrDefault();
                if (curStepObj == null)
                {
                    continue;
                }
                if (arrUserStr.Length <= 1)
                {
                    //如果被跳过的审批没有选择人员,则在这里进行保存
                    var oldRels = oldRelList.Where(t => t.Int("stepId") == stepId).ToList();
                    if (oldRels.Count > 0)
                    {
                        var skipStr = "1";
                        if (skipStepIds.Contains(stepId.ToString()))
                        {
                            oldRels = oldRels.Where(t => t.Int("isSkip") == 0).ToList();
                        }
                        else
                        {
                            oldRels = oldRels.Where(t => t.Int("isSkip") == 1).ToList();
                            skipStr = "0";
                        }
                        if (oldRels.Count > 0)
                        {
                            foreach (var oldRel in oldRels)
                            {
                                var tempData = new StorageData();
                                tempData.Name     = "InstanceActionUser";
                                tempData.Type     = StorageType.Update;
                                tempData.Query    = Query.EQ("inActId", oldRel.Text("inActId"));
                                tempData.Document = new BsonDocument().Add("isSkip", skipStr);

                                storageList.Add(tempData);
                            }
                        }
                    }
                    else if (skipStepIds.Contains(stepId.ToString()))
                    {
                        var tempData = new StorageData();
                        tempData.Name = "InstanceActionUser";
                        tempData.Type = StorageType.Insert;

                        BsonDocument actionUser = new BsonDocument();
                        actionUser.Add("flowInstanceId", curFlowInstance.Text("flowInstanceId"));
                        actionUser.Add("actionConditionId", curFlowInstance.Text("flowInstanceId"));
                        actionUser.Add("userId", "");
                        actionUser.Add("stepId", stepId);
                        actionUser.Add("isSkip", "1");
                        //新增模板属性对象
                        flowHelper.CopyFlowStepProperty(actionUser, curStepObj);
                        tempData.Document = actionUser;
                        storageList.Add(tempData);
                    }
                    continue;
                }
                var userArrayIds = arrUserStr[1];
                var userIds      = userArrayIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var userId in userIds)
                {
                    var oldRel = oldRelList.FirstOrDefault(i => i.Int("stepId") == stepId && i.Text("userId") == userId);
                    if (oldRel.IsNullOrEmpty())
                    {
                        var tempData = new StorageData();
                        tempData.Name = "InstanceActionUser";
                        tempData.Type = StorageType.Insert;

                        BsonDocument actionUser = new BsonDocument();
                        actionUser.Add("flowInstanceId", curFlowInstance.Text("flowInstanceId"));
                        actionUser.Add("actionConditionId", curFlowInstance.Text("flowInstanceId"));
                        actionUser.Add("userId", userId);
                        actionUser.Add("stepId", stepId);
                        //新增模板属性对象
                        flowHelper.CopyFlowStepProperty(actionUser, curStepObj);
                        if (curStepObj.Int("actTypeId") == 2)//如果是会签步骤
                        {
                            actionUser.Set("status", status);
                        }
                        //判断步骤是否跳过审批--袁辉
                        if (skipStepIds.Contains(stepId.ToString()))
                        {
                            actionUser.Add("isSkip", "1");
                        }
                        else
                        {
                            actionUser.Add("isSkip", "0");
                        }
                        tempData.Document = actionUser;
                        storageList.Add(tempData);
                    }
                    else
                    {
                        var tempData = new StorageData();
                        tempData.Name  = "InstanceActionUser";
                        tempData.Type  = StorageType.Update;
                        tempData.Query = Query.EQ("inActId", oldRel.Text("inActId"));
                        BsonDocument actionUser = new BsonDocument();
                        if (hitStepIds.Contains(stepId))
                        {
                            actionUser.Add("status", status);
                        }
                        actionUser.Add("converseRefuseStepId", "");
                        actionUser.Add("actionAvaiable", "");
                        flowHelper.CopyFlowStepProperty(actionUser, curStepObj);

                        //判断步骤是否跳过审批--袁辉
                        if (skipStepIds.Contains(stepId.ToString()))
                        {
                            actionUser.Add("isSkip", "1");
                        }
                        else
                        {
                            actionUser.Add("isSkip", "0");
                        }
                        tempData.Document = actionUser;
                        storageList.Add(tempData);

                        oldRelList.Remove(oldRel);
                    }
                }
            }
            foreach (var oldRel in oldRelList)
            {
                var tempData = new StorageData();
                tempData.Name  = "InstanceActionUser";
                tempData.Type  = StorageType.Delete;
                tempData.Query = Query.EQ("inActId", oldRel.Text("inActId"));
                storageList.Add(tempData);
            }

            tempResult = dataOp.BatchSaveStorageData(storageList);
            if (tempResult.Status == Status.Failed)
            {
                json.Success = false;
                json.Message = "保存审批人员失败";
                return(Json(json));
            }
            #endregion

            #endregion

            #region 提交时保存提交信息并跳转
            if (saveStatus == 1)//提交时直接发起
            {
                //保存发起人
                BsonDocument tempData = new BsonDocument().Add("approvalUserId", dataOp.GetCurrentUserId().ToString()).Add("instanceStatus", "0");
                tempResult = dataOp.Save("BusFlowInstance", Query.EQ("flowInstanceId", curFlowInstance.Text("flowInstanceId")), tempData);
                if (tempResult.Status == Status.Failed)
                {
                    json.Success = false;
                    json.Message = "保存发起人失败";
                    return(Json(json));
                }
                //保存发起时间
                var timeFormat = "yyyy-MM-dd HH:mm:ss";
                tempData = new BsonDocument()
                {
                    { "startTime", DateTime.Now.ToString(timeFormat) }
                };
                tempResult = dataOp.Save("ProgrammeEvaluation", Query.EQ("proEvalId", proEvalId.ToString()), tempData);
                if (tempResult.Status == Status.Failed)
                {
                    json.Success = false;
                    json.Message = "保存发起时间失败";
                    return(Json(json));
                }
                //跳转步骤
                BsonDocument act = dataOp.FindAllByKeyVal("BusFlowAction", "type", "0").FirstOrDefault();
                tempResult = helper.ExecAction(curFlowInstance, act.Int("actId"), null, bootStep.Int("stepId"));
                if (tempResult.Status == Status.Failed)
                {
                    json.Success = false;
                    json.Message = "流程跳转失败:" + tempResult.Message;
                    return(Json(json));
                }
            }
            #endregion

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Пример #8
0
        /// <summary>
        /// 初始化当前页面模板数据
        /// </summary>
        protected void InitPageTemplate()
        {
            //获取要生成的栏目ID
            channelID = Utils.GetQueryInt("ID");
            if (channelID < 0)
            {
                Message.Dialog("生成错误,生成静态页的栏目ID为空!", "-1", MessageIcon.Warning);
            }

            //获取栏目类型
            channelType = Utils.GetQueryString("type");
            if (channelType.Length == 0)
            {
                ArcListBLL arclistBll = new ArcListBLL();
                channelType = arclistBll.GetChannelType(channelID);
            }

            //获取记录总数
            totalRecord = Utils.GetQueryInt("total");
            if (totalRecord < 0)
            {
                ArcListBLL arclistBll = new ArcListBLL();
                totalRecord = arclistBll.GetArcCount(channelID, channelType);
            }

            //获取生成栏目当前页数
            pageIndex = Utils.GetQueryInt("page");
            if (pageIndex < 0)
            {
                Message.Dialog("生成错误,生成静态页的当前页数为空!", "-1", MessageIcon.Warning);
            }

            //获取分页大小
            pageSize = Utils.GetQueryInt("size");
            //获取分页选项
            pageItem = this.__PAGEITEM.Value;
            if (pageSize < 0 || pageItem.Length == 0)
            {
                //分页大小和分页选项从PageList标签中获取
                ElementCollection <Tag> tags = this.Document.GetChildTagsByTagName("PageList");
                foreach (Tag tag in tags)
                {
                    pageSize = TypeConvert.ToInt32(tag.Attributes["PageSize"].Value);
                    pageItem = tag.Attributes["Item"].Value.ToString();
                }
                this.__PAGEITEM.Value = pageItem;
            }

            //获取栏目当前位置
            classUrl    = this.__CLASSURL.Value;
            listTemplet = this.__LISTTEMPLET.Value;
            indexRule   = this.__INDEXRULE.Value;
            position    = this.__POSITION.Value;
            relation    = this.__RELATION.Value;
            if (classUrl.Length == 0 || listTemplet.Length == 0 || indexRule.Length == 0 || relation.Length == 0)
            {
                Arc_ClassBLL classBll  = new Arc_ClassBLL();
                Arc_Class    classInfo = classBll.GetModel(channelID);
                classUrl    = this.__CLASSURL.Value = classInfo.ClassPath;
                listTemplet = this.__LISTTEMPLET.Value = classInfo.ListTemplet;
                indexRule   = this.__INDEXRULE.Value = classInfo.IndexRule;
                relation    = this.__RELATION.Value = classInfo.Relation.TrimEnd('.').Replace('.', ',');
            }
            if (position.Length == 0)
            {
                Arc_ClassBLL classBll = new Arc_ClassBLL();
                DataTable    dt       = classBll.GetThisPlace(relation);

                position += "<a href=\"/\">首页</a> &raquo; ";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    position += "<a href=\"" + dt.Rows[i]["ClassEName"] + "\">" + dt.Rows[i]["ClassName"] + "</a>";
                    if (i + 1 < dt.Rows.Count)
                    {
                        position += " &raquo; ";
                    }
                }
                this.__POSITION.Value = position;
            }

            //设置自定义属性
            PageListField field = new PageListField();

            field.CurrentPage = pageIndex;
            field.TotalPage   = PageSeting.GetPageCount(totalRecord, pageSize);
            field.TotalRecord = totalRecord;
            field.PageIndex   = PageSeting.GetPageNum(pageIndex, field.TotalPage, 10, "createlist.aspx?id=10&page={0}", pageItem);
            field.Position    = position;
            //gobal.PageIndex = gobal.PageIndex.Replace(string.Format("list/{0}/1/", channelID), "index.html");
            this.Document.Variables.SetValue("field", field);
        }
Пример #9
0
        public void TypeConvert_Impl_EnumActualNull()
        {
            var value = TypeConvert.To <StringComparison?>("");

            Assert.Null(value);
        }
Пример #10
0
        public async Task Test_EntityMapperPerformanceAsync(int index)
        {
            index++;
            IDatabase database = _mysql;

            var books = Mocker.GetBooks(5000);

            var trans = await _mysqlTransaction.BeginTransactionAsync <BookEntity>().ConfigureAwait(false);

            IEnumerable <BookEntity> re = await database.RetrieveAsync <BookEntity>(b => b.Deleted, trans).ConfigureAwait(false);

            await database.AddAsync(Mocker.GetBooks(1)[0], "", trans).ConfigureAwait(false);

            try
            {
                //await database.AddAsync<BookEntity>(books[0], "", trans);

                await database.BatchAddAsync(books, "x", trans).ConfigureAwait(false);

                await _mysqlTransaction.CommitAsync(trans).ConfigureAwait(false);
            }
            catch
            {
                await _mysqlTransaction.RollbackAsync(trans).ConfigureAwait(false);
            }


            Stopwatch stopwatch = new Stopwatch();

            using MySqlConnection mySqlConnection = new MySqlConnection(_mysqlConnectionString);

            TypeHandlerHelper.AddTypeHandlerImpl(typeof(DateTimeOffset), new DateTimeOffsetTypeHandler(), false);

            //time = 0;
            int loop = 100;

            TimeSpan time0 = TimeSpan.Zero, time1 = TimeSpan.Zero, time2 = TimeSpan.Zero, time3 = TimeSpan.Zero;

            for (int cur = 0; cur < loop; ++cur)
            {
                await mySqlConnection.OpenAsync().ConfigureAwait(false);


                using MySqlCommand command0 = new MySqlCommand("select * from tb_bookentity limit 10000", mySqlConnection);

                var reader0 = await command0.ExecuteReaderAsync().ConfigureAwait(false);

                List <BookEntity> list1 = new List <BookEntity>();
                List <BookEntity> list2 = new List <BookEntity>();
                List <BookEntity> list3 = new List <BookEntity>();

                int len = reader0.FieldCount;
                EntityPropertyDef[] propertyDefs = new EntityPropertyDef[len];
                MethodInfo[]        setMethods   = new MethodInfo[len];

                EntityDef definition = EntityDefFactory.GetDef <BookEntity>() !;

                for (int i = 0; i < len; ++i)
                {
                    propertyDefs[i] = definition.GetPropertyDef(reader0.GetName(i)) !;
                    setMethods[i]   = propertyDefs[i].SetMethod;
                }


                Func <IDataReader, object> mapper1 = EntityMapperDelegateCreator.CreateToEntityDelegate(definition, reader0, 0, definition.FieldCount, false, Database.Engine.EngineType.MySQL);

                //Warning: �����Dapper��С��DateTimeOffset�Ĵ洢���ᶪʧoffset��Ȼ��ת����ʱ�򣬻���ϵ���ʱ���offset
                Func <IDataReader, object> mapper2 = DataReaderTypeMapper.GetTypeDeserializerImpl(typeof(BookEntity), reader0);



                Stopwatch stopwatch1 = new Stopwatch();
                Stopwatch stopwatch2 = new Stopwatch();
                Stopwatch stopwatch3 = new Stopwatch();



                while (reader0.Read())
                {
                    stopwatch1.Start();

                    object obj1 = mapper1(reader0);

                    list1.Add((BookEntity)obj1);
                    stopwatch1.Stop();



                    stopwatch2.Start();
                    object obj2 = mapper2(reader0);

                    list2.Add((BookEntity)obj2);
                    stopwatch2.Stop();


                    stopwatch3.Start();

                    BookEntity item = new BookEntity();

                    for (int i = 0; i < len; ++i)
                    {
                        EntityPropertyDef property = propertyDefs[i];

                        object?value = TypeConvert.DbValueToTypeValue(reader0[i], property, Database.Engine.EngineType.MySQL);

                        if (value != null)
                        {
                            setMethods[i].Invoke(item, new object?[] { value });
                        }
                    }

                    list3.Add(item);

                    stopwatch3.Stop();
                }

                time1 += stopwatch1.Elapsed;
                time2 += stopwatch2.Elapsed;
                time3 += stopwatch3.Elapsed;

                await reader0.DisposeAsync().ConfigureAwait(false);

                command0.Dispose();

                await mySqlConnection.CloseAsync().ConfigureAwait(false);
            }

            _output.WriteLine("Emit Coding : " + (time1.TotalMilliseconds / (loop * 1.0)).ToString(CultureInfo.InvariantCulture));
            _output.WriteLine("Dapper : " + (time2.TotalMilliseconds / (loop * 1.0)).ToString(CultureInfo.InvariantCulture));
            _output.WriteLine("Reflection : " + (time3.TotalMilliseconds / (loop * 1.0)).ToString(CultureInfo.InvariantCulture));
        }
Пример #11
0
        public ActionResult SavePostInfo(FormCollection saveForm)
        {
            InvokeResult  result = new InvokeResult();
            DataOperation dataOp = new DataOperation();

            #region 构建数据
            string tbName   = saveForm["tbName"] != null ? saveForm["tbName"] : "";
            string queryStr = saveForm["queryStr"] != null ? saveForm["queryStr"] : "";
            string dataStr  = saveForm["dataStr"] != null ? saveForm["dataStr"] : "";

            if (dataStr.Trim() == "")
            {
                foreach (var tempKey in saveForm.AllKeys)
                {
                    if (tempKey == "tbName" || tempKey == "queryStr" || tempKey.Contains("fileList[") || tempKey.Contains("param."))
                    {
                        continue;
                    }

                    dataStr += string.Format("{0}={1}&", tempKey, saveForm[tempKey]);
                }
            }
            #endregion

            #region 保存数据
            BsonDocument curData = new BsonDocument();  //当前数据,即操作前数据

            if (queryStr.Trim() != "")
            {
                curData = dataOp.FindOneByQuery(tbName, TypeConvert.NativeQueryToQuery(queryStr));
            }

            result = dataOp.Save(tbName, queryStr, dataStr);

            #endregion

            #region 文件上传
            int       primaryKey = 0;
            TableRule rule       = new TableRule(tbName);

            ColumnRule columnRule = rule.ColumnRules.Where(t => t.IsPrimary == true).FirstOrDefault();
            string     keyName    = columnRule != null ? columnRule.Name : "";
            if (!string.IsNullOrEmpty(queryStr))
            {
                var query     = TypeConvert.NativeQueryToQuery(queryStr);
                var recordDoc = dataOp.FindOneByQuery(tbName, query);
                saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                if (recordDoc != null)
                {
                    primaryKey = recordDoc.Int(keyName);
                }
            }

            if (primaryKey == 0)//新建
            {
                if (saveForm["tableName"] != null)
                {
                    string str = result.BsonInfo.Text(keyName);
                    saveForm["keyValue"] = result.BsonInfo.Text(keyName);
                    string t = saveForm["keyValue"].ToString();
                    string c = result.BsonInfo.String(keyName);
                    t = "";
                }
            }
            else//编辑
            {
                #region  除文件
                string delFileRelIds = saveForm["delFileRelIds"] != null ? saveForm["delFileRelIds"] : "";
                if (!string.IsNullOrEmpty(delFileRelIds))
                {
                    FileOperationHelper opHelper = new FileOperationHelper();
                    try
                    {
                        string[] fileArray;
                        if (delFileRelIds.Length > 0)
                        {
                            fileArray = delFileRelIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            if (fileArray.Length > 0)
                            {
                                foreach (var item in fileArray)
                                {
                                    result = opHelper.DeleteFileByRelId(int.Parse(item));
                                    if (result.Status == Status.Failed)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        result.Status  = Status.Failed;
                        result.Message = ex.Message;
                        return(Json(TypeConvert.InvokeResultToPageJson(result)));
                    }
                }
                #endregion

                saveForm["keyValue"] = primaryKey.ToString();
            }
            result.FileInfo = SaveMultipleUploadFiles(saveForm);
            #endregion

            #region 保存日志
            if (result.Status == Status.Successful)
            {
                //dataOp.LogDataStorage(tbName, queryStr.Trim() == "" ? StorageType.Insert : StorageType.Update, curData, result.BsonInfo);
            }
            #endregion

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Пример #12
0
        public static string CreateCode(Dictionary <string, dynamic> CreateCodeDic)
        {
            string usings = CreateCodeDic["Using"];                                             //Using

            string[] usingsArray         = usings.Split(';');
            string   NameSpace           = CreateCodeDic["NameSpace"];                          //NameSpace
            string   NameSpaceCommonPlus = CreateCodeDic["NameSpaceCommonPlus"];                //NameSpaceCommonPlus
            string   TableName           = CreateCodeDic["TableName"];                          //TableName
            string   ClassName           = CreateCodeDic["Class"];                              //ClassName
            string   ClassNamePlus       = CreateCodeDic["ClassNamePlus"];                      //ClassName Plus
            string   ClassNameExtends    = CreateCodeDic["ClassExtends"];                       //ClassExtends

            if (!string.IsNullOrEmpty(ClassNameExtends))
            {
                ClassNameExtends = ":" + ClassNameExtends;
            }
            string        ClassNameAndExtends = ClassName + ClassNamePlus + ClassNameExtends;   //Class whole name
            List <string> FeildName           = CreateCodeDic["FeildName"];                     //表字段名称
            List <string> FeildType           = CreateCodeDic["FeildType"];                     //表字段类型
            List <string> FeildLength         = CreateCodeDic["FeildLength"];                   //表字段长度
            List <string> FeildIsNullable     = CreateCodeDic["FeildIsNullable"];               //表字段可空
            List <string> FeildDescription    = CreateCodeDic["FeildDescription"];              //表字段说明
            List <string> FeildIsPK           = CreateCodeDic["FeildIsPK"];                     //表字段是否主键
            List <string> FeildIsIdentity     = CreateCodeDic["FeildIsIdentity"];               //表字段是否自增

            StringBuilder str = new StringBuilder();

            //foreach (var item in usingsArray)
            //{
            //    if (usingsArray.Last().Equals(item))
            //    {
            //        break;
            //    }
            //    str.Append($"{item};\r\n");
            //}

            #region 版权信息
            //版权信息
            str.Append(Info.CopyRight);
            str.Append("\r\n");
            #endregion

            //添加using
            str.Append($"{usings}\r\n");
            str.Append("\r\n");//引用结束换行

            //添加命名空间
            str.Append($"namespace {NameSpace}{NameSpaceCommonPlus}\r\n");
            str.Append("{" + "\r\n");

            //添加实体类
            str.Append("\t" + "/// <summary>" + "\r\n");
            str.Append("\t" + "/// public class " + ClassName + ClassNamePlus + "\r\n");
            str.Append("\t" + "/// </summary>" + "\r\n");
            str.Append("\t" + "[Serializable]" + "\r\n");
            str.Append("\t" + $"public class {ClassNameAndExtends}\r\n");
            str.Append("\t" + "{" + "\r\n");
            //添加构造方法
            str.Append("\t\t" + "/// <summary>" + "\r\n");
            str.Append("\t\t" + "/// construction method" + "\r\n");
            str.Append("\t\t" + "/// </summary>" + "\r\n");
            str.Append("\t\t" + "public " + ClassName + ClassNamePlus + "()" + "\r\n");
            str.Append("\t\t" + "{}" + "\r\n" + "\r\n");
            //add filed
            for (int i = 0; i < FeildName.Count; i++)
            {
                //str.Append($"\t\t{TypeConvert.RT_PK_Attribute(FeildIsPK[i])}\r\n");
                string IsNull = SqlTypeConvert.SqlTypeToLanguageType(CommonVariables.currentDataBaseType, Options.Opt_Language.Net, FeildType[i]).Equals("String") ? "" : TypeConvert.RT_Nullable(FeildIsNullable[i]);
                str.Append("\t\t" + $"//{ TypeConvert.RT_PK(FeildIsPK[i])} {FeildDescription[i]}" + "\r\n");
                str.Append("\t\t" + $"public {SqlTypeConvert.SqlTypeToLanguageType(CommonVariables.currentDataBaseType, Options.Opt_Language.Net, FeildType[i])}{IsNull} {FeildName[i]} {"{ get;set; }"}" + "\r\n");
            }

            str.Append("\t" + "}" + "\r\n"); //public class }
            str.Append("}" + "\r\n");        //namespace class }

            return(str.ToString());
        }
        public string GetRoomInfo(long roomId)
        {
            var model = RoomBll.GetById(roomId);
            List <RoomPrice> priceList = null;

            if (model != null)
            {
                //根据房型id获取房价方案
                priceList = RoomPriceBll.GetList(UserContext.CurrentUser.HotelId, model.RoomTypeId);
            }
            else
            {
                model = new Room();
            }

            Hotel.Model.RoomReg reg = null;

            if (model.RoomRegId != 0)
            {
                reg = RoomRegBll.GetById(model.RoomRegId);
            }

            var roomType   = RoomTypeBll.GetById(model.RoomTypeId);
            var HolidaySet = HolidaySetBll.GetList(UserContext.CurrentUser.HotelId);
            var WeekendSet = WeekendSetBll.GetByHotelId(UserContext.CurrentUser.HotelId);

            var    SalePrice = model.Price;  //价
            double SaleRate  = 1.0;          //折扣率

            if (roomType.IsAllowWeekendRoom) //周末价判断
            {
                if (WeekendSet.IsMonday && DateTime.Now.DayOfWeek == DayOfWeek.Monday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsTuesday && DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsWednesday && DateTime.Now.DayOfWeek == DayOfWeek.Wednesday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsThursday && DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsFriday && DateTime.Now.DayOfWeek == DayOfWeek.Friday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsSaturday && DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsSunday && DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
            }
            if (roomType.IsAllowHolidayRoom) //假日价
            {
                foreach (var h in HolidaySet)
                {
                    var start = TypeConvert.IntToDateTime(h.StartDate);
                    var end   = TypeConvert.IntToDateTime(h.EndDate).AddDays(1).AddSeconds(-1); //定位在这天最后一秒
                    if (DateTime.Now > start && DateTime.Now < end)
                    {
                        SalePrice = roomType.HolidayPrice;
                    }
                }
            }



            SaleRate = Convert.ToDouble(SalePrice) / Convert.ToDouble(model.Price);


            return(JsonConvert.SerializeObject(new
            {
                Room = model,
                RoomPrice = roomType.Price,
                SalePrice = SalePrice,
                SaleRate = SaleRate,
                PriceList = priceList,
                RoomReg = reg
            }));
        }
Пример #14
0
        /// <summary>
        /// 画直方图数据到Bitmap中
        /// </summary>
        public Bitmap RefreshBackGroundImage(Size ShowSize, Color DrawColor, Color BackColor, Color axisColor, int cmin, int cmax, int OffX)
        {
            if (numMostValue <= 1 || lenValue <= 1)
            {
                return(null);
            }

            Bitmap   histBmp = TypeConvert.ConvertToBitmap(ShowSize, BackColor);
            Graphics gp      = Graphics.FromImage(histBmp);

            int c1 = GetValuePosition(cmin);
            int c2 = GetValuePosition(cmax);

            Point[] tmp = new Point[c1 + 2];
            for (int i = 0; i < c1; i++)
            {
                tmp[i].X = DrawPoint[i].X;
                tmp[i].Y = DrawPoint[i].Y;
            }
            tmp[c1].X     = c1 - 1;
            tmp[c1].Y     = ShowSize.Height - 1;
            tmp[c1 + 1].X = 0;
            tmp[c1 + 1].Y = ShowSize.Height - 1;
            gp.FillPolygon(new SolidBrush(Color.WhiteSmoke), tmp, System.Drawing.Drawing2D.FillMode.Winding);

            tmp = new Point[c2 - c1 + 2];
            for (int i = c1; i < c2; i++)
            {
                tmp[i - c1].X = DrawPoint[i].X;
                tmp[i - c1].Y = DrawPoint[i].Y;
            }
            tmp[c2 - c1].X     = c2 - 1;
            tmp[c2 - c1].Y     = ShowSize.Height - 1;
            tmp[c2 - c1 + 1].X = c1;
            tmp[c2 - c1 + 1].Y = ShowSize.Height - 1;
            gp.FillPolygon(new SolidBrush(DrawColor), tmp, System.Drawing.Drawing2D.FillMode.Winding);

            if (DrawSize.Width > c2)
            {
                tmp = new Point[DrawSize.Width - c2 + 1];
                for (int i = c2 + 1; i < DrawSize.Width; i++)
                {
                    tmp[i - c2 - 1].X = DrawPoint[i].X;
                    tmp[i - c2 - 1].Y = DrawPoint[i].Y;
                }
                tmp[DrawSize.Width - c2 - 1].X = ShowSize.Width - 1;
                tmp[DrawSize.Width - c2 - 1].Y = ShowSize.Height - 1;
                tmp[DrawSize.Width - c2].X     = c2;
                tmp[DrawSize.Width - c2].Y     = ShowSize.Height - 1;
                gp.FillPolygon(new SolidBrush(Color.WhiteSmoke), tmp, System.Drawing.Drawing2D.FillMode.Winding);
            }

            //Axis
            Point p0  = new Point(0, ShowSize.Height);
            Point px  = new Point(ShowSize.Width, ShowSize.Height);
            Point py  = new Point(0, 0);
            Pen   pen = new Pen(axisColor);

            gp.DrawLine(pen, p0, px);
            gp.DrawLine(pen, p0, py);
            gp.Dispose();

            return(histBmp);
        }
Пример #15
0
        /// <summary>
        /// 画直方图数据到Bitmap中
        /// </summary>
        public Bitmap DrawHistBmp(Size ShowSize, Color DrawColor, Color BackColor, Color axisColor)
        {
            DrawSize = ShowSize;
            if (numMostValue < 1 || lenValue <= 1)
            {
                return(null);
            }

            Bitmap   histBmp = TypeConvert.ConvertToBitmap(ShowSize, BackColor);
            Graphics gp      = Graphics.FromImage(histBmp);

            float k_width = (float)(ShowSize.Width) / lenValue;

            DrawPoint = new Point[ShowSize.Width];
            float idx  = 0;
            int   sn   = 0;
            int   max  = 0;
            float unit = lenValue / (float)ShowSize.Width;

            for (int i = 0; i < ShowSize.Width; i++)
            {
                int y = 0;
                while (idx < i + 1 && sn < lenValue)
                {
                    idx += k_width;
                    y   += histogramData[sn++];
                }
                DrawPoint[i].Y = y;
                if (max < y)
                {
                    max = y;
                }
            }

            //float k_height = (float)(ShowSize.Height) / max * 4;
            float k_height = (float)(ShowSize.Height / (float)numMostValue);

            for (int i = 0; i < ShowSize.Width; i++)
            {
                DrawPoint[i].X = i;
                int y = (int)(DrawPoint[i].Y / unit * k_height + 0.5);
                if (y > ShowSize.Height - 1)
                {
                    y = ShowSize.Height - 1;
                }
                DrawPoint[i].Y = ShowSize.Height - y;
            }

            //draw
            Point[] drawPoint = new Point[DrawPoint.Length + 2];
            for (int i = 0; i < DrawPoint.Length; i++)
            {
                drawPoint[i].X = DrawPoint[i].X;
                drawPoint[i].Y = DrawPoint[i].Y;
            }
            drawPoint[ShowSize.Width].X     = ShowSize.Width - 1;
            drawPoint[ShowSize.Width].Y     = ShowSize.Height - 1;
            drawPoint[ShowSize.Width + 1].X = 0;
            drawPoint[ShowSize.Width + 1].Y = ShowSize.Height - 1;
            gp.FillPolygon(new SolidBrush(DrawColor), drawPoint, System.Drawing.Drawing2D.FillMode.Winding);

            //Axis
            Point p0  = new Point(0, ShowSize.Height);
            Point px  = new Point(ShowSize.Width, ShowSize.Height);
            Point py  = new Point(0, 0);
            Pen   pen = new Pen(axisColor);

            gp.DrawLine(pen, p0, px);
            gp.DrawLine(pen, p0, py);
            gp.Dispose();

            return(histBmp);
        }
Пример #16
0
        public void TypeConvert_GuidActualNull()
        {
            var value = TypeConvert.To <Guid?>("");

            Assert.Null(value);
        }
Пример #17
0
        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <returns></returns>
        protected virtual object GetDataSource()
        {
            ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings[this.Connection.GetTextValue()];

            if (setting == null)
            {
                return(null);
            }

            DbProviderFactory dbFactory = Utility.CreateDbProviderFactory(setting.ProviderName);

            if (dbFactory == null)
            {
                return(null);
            }

            object result = null;

            using (DbConnection dbConnection = dbFactory.CreateConnection())
            {
                dbConnection.ConnectionString = setting.ConnectionString;
                using (DbCommand dbCommand = dbConnection.CreateCommand())
                {
                    dbCommand.CommandType = this.CommandType == null ? System.Data.CommandType.Text : (System.Data.CommandType)Utility.ConvertTo(this.CommandType.GetTextValue(), typeof(System.Data.CommandType));
                    dbCommand.CommandText = this.CommandText.GetTextValue();

                    if (this.Parameters.Count > 0)
                    {
                        string        format    = this.ParameterFormat == null ? "@p{0}" : this.ParameterFormat.GetTextValue();
                        List <object> expParams = new List <object>();
                        for (int i = 0; i < this.Parameters.Count; i++)
                        {
                            IExpression exp         = this.Parameters[i];
                            DbParameter dbParameter = dbFactory.CreateParameter();
                            object      value       = exp.GetValue();
                            dbParameter.ParameterName = string.IsNullOrEmpty(format) ? "?" : string.Format(format, i);
                            dbParameter.DbType        = Utility.GetObjectDbType(value);
                            dbParameter.Value         = value;
                            dbCommand.Parameters.Add(dbParameter);
                        }
                    }

                    using (DbDataAdapter dbAdapter = dbFactory.CreateDataAdapter())
                    {
                        dbAdapter.SelectCommand = dbCommand;
                        DataTable table = new DataTable();
                        dbAdapter.Fill(table);

                        if (this.RowIndex != null)
                        {
                            //只获取其中的某行数据
                            int row = TypeConvert.ToInt32(this.RowIndex.GetTextValue());
                            if (table.Rows.Count > row)
                            {
                                result = table.Rows[row];
                            }
                        }
                        else
                        {
                            result = table;
                        }
                    }
                }
            }
            return(result);
        }
Пример #18
0
        public void TypeConvert_DateTimeActualNull()
        {
            var value = TypeConvert.To <DateTime?>("");

            Assert.Null(value);
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            Guid   gPARENT_ID   = CommonTypeConvert.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            CommonProcedure.ParentGet(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            if (e.CommandName == "Save")
            {
                var txtNAME = FindControl("NAME") as TextBox;
                var txtPRODUCT_TEMPLATE_ID = FindControl("PRODUCT_TEMPLATE_ID") as HtmlInputHidden;
                if (CommonTypeConvert.IsEmptyString(txtNAME.Text.Trim()))
                {
                    txtPRODUCT_TEMPLATE_ID.Value = String.Empty;
                }
                else if (CommonTypeConvert.IsEmptyString(txtPRODUCT_TEMPLATE_ID.Value))
                {
                    txtPRODUCT_TEMPLATE_ID.Value = Guid.Empty.ToString();
                }

                ValidateEditViewFields(m_sMODULE + ".EditView");
                ValidateEditViewFields(m_sMODULE + ".CostView");
                ValidateEditViewFields(m_sMODULE + ".MftView");
                if (Page.IsValid)
                {
                    string    sCUSTOM_MODULE = "PRODUCTS";
                    DataTable dtCustomFields = CRMCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    var       oQuery         = new InlineQueryDBManager();
                    DataRow   rowCurrent     = null;
                    if (!CommonTypeConvert.IsEmptyGuid(gID))
                    {
                        string innerSql = ApplicationSQL.SQL["Products_EditView"].ToString();
                        oQuery.CommandText = innerSql;
                        CRMSecurity.Filter(oQuery, m_sMODULE, "edit");
                        TypeConvert.AppendParameter(oQuery, gID, "ID", false);
                        DataTable dtCurrent = oQuery.GetTable();
                        if (dtCurrent.Rows.Count > 0)
                        {
                            rowCurrent = dtCurrent.Rows[0];
                        }
                        else
                        {
                            gID = Guid.Empty;
                        }
                    }

                    CommonProcedure.ProductUpdate
                        (ref gID
                        , new DynamicControl(this, rowCurrent, "PRODUCT_TEMPLATE_ID").ID
                        , new DynamicControl(this, rowCurrent, "NAME").Text
                        , new DynamicControl(this, rowCurrent, "STATUS").SelectedValue
                        , new DynamicControl(this, rowCurrent, "ACCOUNT_ID").ID
                        , new DynamicControl(this, rowCurrent, "CONTACT_ID").ID
                        , new DynamicControl(this, rowCurrent, "QUANTITY").IntegerValue
                        , new DynamicControl(this, rowCurrent, "DATE_PURCHASED").DateValue
                        , new DynamicControl(this, rowCurrent, "DATE_SUPPORT_EXPIRES").DateValue
                        , new DynamicControl(this, rowCurrent, "DATE_SUPPORT_STARTS").DateValue
                        , new DynamicControl(this, rowCurrent, "MANUFACTURER_ID").ID
                        , new DynamicControl(this, rowCurrent, "CATEGORY_ID").ID
                        , new DynamicControl(this, rowCurrent, "TYPE_ID").ID
                        , new DynamicControl(this, rowCurrent, "WEBSITE").Text
                        , new DynamicControl(this, rowCurrent, "MFT_PART_NUM").Text
                        , new DynamicControl(this, rowCurrent, "VENDOR_PART_NUM").Text
                        , new DynamicControl(this, rowCurrent, "SERIAL_NUMBER").Text
                        , new DynamicControl(this, rowCurrent, "ASSET_NUMBER").Text
                        , new DynamicControl(this, rowCurrent, "TAX_CLASS").SelectedValue
                        , new DynamicControl(this, rowCurrent, "WEIGHT").FloatValue
                        , new DynamicControl(this, rowCurrent, "CURRENCY_ID").ID
                        , new DynamicControl(this, rowCurrent, "COST_PRICE").DecimalValue
                        , new DynamicControl(this, rowCurrent, "LIST_PRICE").DecimalValue
                        , new DynamicControl(this, rowCurrent, "BOOK_VALUE").DecimalValue
                        , new DynamicControl(this, rowCurrent, "BOOK_VALUE_DATE").DateValue
                        , new DynamicControl(this, rowCurrent, "DISCOUNT_PRICE").DecimalValue
                        , new DynamicControl(this, rowCurrent, "PRICING_FACTOR").IntegerValue
                        , new DynamicControl(this, rowCurrent, "PRICING_FORMULA").SelectedValue
                        , new DynamicControl(this, rowCurrent, "SUPPORT_NAME").Text
                        , new DynamicControl(this, rowCurrent, "SUPPORT_CONTACT").Text
                        , new DynamicControl(this, rowCurrent, "SUPPORT_DESCRIPTION").Text
                        , new DynamicControl(this, rowCurrent, "SUPPORT_TERM").SelectedValue
                        , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text
                        , new DynamicControl(this, rowCurrent, "TEAM_ID").ID
                        );
                    CRMDynamic.UpdateCustomFields(this, gID, sCUSTOM_MODULE, dtCustomFields);

                    if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/CRM/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID);
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID);
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!CommonTypeConvert.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/CRM/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID);
                }
                else if (CommonTypeConvert.IsEmptyGuid(gID))
                {
                    Response.Redirect("Index.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID);
                }
            }
        }
Пример #20
0
 public void TypeConvert_Double(string culture)
 {
     CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture);
     Assert.Equal(0.2, TypeConvert.To <double>("0.2"));
     Assert.Equal(2, TypeConvert.To <double>("0,2"));
 }
Пример #21
0
        /// <summary>
        /// Admin mute user
        /// </summary>
        void AdminMute(OnlineUser user, CommandPacket command)
        {
            User backendUser = Users[user.Username];
            var  arguments   = command.arguments;

            //  Permission check
            if (backendUser.permissionLevel < 1)
            {
                PermissionDeniedMessage(user);
                return;
            }
            //  Syntax check
            if (arguments.Count != 2)
            {
                ServerMessage(
                    "server",
                    user,
                    langFile["command_arguments_error"]
                    .Replace("$COUNT$", "2")
                    );
                return;
            }
            //  Check if the user is exist
            if (!Users.ContainsKey(arguments[0]))
            {
                ServerMessage(
                    "server",
                    user,
                    langFile["command_userNotExist"]
                    .Replace("$NAME$", arguments[0])
                    );
                return;
            }
            //  Check permission level
            User target = Users[arguments[0]];

            if (target.permissionLevel >= backendUser.permissionLevel)
            {
                ServerMessage(
                    "server",
                    user,
                    langFile["command_higherPermission"]
                    .Replace("$NICK$", target.nickname)
                    .Replace("$NAME$", target.username)
                    );
                return;
            }
            //  Convert time
            DateTime time;

            if (!TypeConvert.TryGetTime(arguments[1], out time))
            {
                ServerMessage(
                    "server",
                    user,
                    langFile["command_invalidTimeFormat"]
                    );
                return;
            }
            //  Calculate time
            DateTime untilTime = DateTime.Now.AddTicks(time.Ticks);

            target.muteTime = untilTime;
            Info(
                $"{backendUser.nickname}\\rr({backendUser.username}\\rr)" +
                $" muted {target.nickname}\\rr({target.username}\\rr)."
                );
            Broadcast(
                "server",
                langFile["command_mute_broadcast"]
                .Replace("$NICK$", target.nickname)
                .Replace("$NAME$", target.username)
                .Replace("$TIME$", untilTime.ToString("yyyy/MM/dd HH:mm:ss"))
                );
            if (OnlineUsers.ContainsKey(arguments[0]))
            {
                ServerMessage(
                    "server",
                    OnlineUsers[arguments[0]],
                    langFile["command_mute_message"]
                    .Replace("$TIME$", untilTime.ToString("yyyy/MM/dd HH:mm:ss"))
                    );
            }
        }
Пример #22
0
        public void TypeConvert_IntActualNull()
        {
            var value = TypeConvert.ToType("", typeof(int?));

            Assert.Null(value);
        }
Пример #23
0
        public override BaseResult Update(dynamic entity)
        {
            BaseResult br    = new BaseResult();
            Hashtable  param = (Hashtable)entity;

            if (param == null || !param.ContainsKey("model") || !param.ContainsKey("id_user"))
            {
                br.Success = false;
                br.Message.Add("拒绝关注参数错误.");
                br.Level = ErrorLevel.Warning;
                br.Data  = "companyName";
                return(br);
            }
            long             id_user     = TypeConvert.ToInt64(param["id_user"], 0);
            Tb_Gys_Cgs_Check gyscgscheck = (Tb_Gys_Cgs_Check)param["model"];
            string           flag_from   = param.ContainsKey("flag_from")?param["flag_from"].ToString(): "pc";

            if (gyscgscheck == null || !gyscgscheck.id.HasValue || !(gyscgscheck.id > 0))
            {
                br.Success = false;
                br.Message.Add("拒绝关注参数错误.");
                br.Level = ErrorLevel.Warning;
                br.Data  = "companyName";
                return(br);
            }

            Hashtable ht = new Hashtable();

            ht.Add("id", gyscgscheck.id);
            var gcgx = DAL.GetItem <Tb_Gys_Cgs_Check>(typeof(Tb_Gys_Cgs_Check), ht);

            if (gcgx == null)
            {
                br.Success = false;
                br.Message.Add("客户的申请已处理过了,请刷新页面.");
                br.Level = ErrorLevel.Warning;
                return(br);
            }
            if (gcgx.flag_form.Equals(Gys_Cgs_Status.Refuse))
            {
                br.Success = false;
                br.Message.Add("客户的申请已被拒绝过了,请刷新页面.");
                br.Level = ErrorLevel.Warning;
                return(br);
            }

            param["id"]             = gyscgscheck.id;
            param["new_flag_state"] = Gys_Cgs_Status.Refuse;
            param["new_refuse"]     = gyscgscheck.refuse;
            DAL.UpdatePart(typeof(Tb_Gys_Cgs_Check), param);

            //记录供采关系日志
            var Loggcgx = new Tb_Gys_Cgs_Log();

            Loggcgx.id_cgs     = gcgx.id_cgs.Value;
            Loggcgx.id_gys     = gcgx.id_gys.Value;
            Loggcgx.id_user    = id_user;
            Loggcgx.flag_state = Gys_Cgs_Status.Refuse;
            Loggcgx.flag_form  = flag_from;
            Loggcgx.contents   = string.Format("[{0}]拒绝[{1}]的申请.", gcgx.mc_gys, gcgx.mc_cgs);
            DAL.Add(Loggcgx);

            br.Message.Add(string.Format("[{0}]拒绝[{1}]的申请.", gcgx.mc_gys, gcgx.mc_cgs));
            br.Success = true;
            return(br);
        }
Пример #24
0
        public void TypeConvert_Impl_IntActualNull()
        {
            var value = TypeConvert.To <int?>("");

            Assert.Null(value);
        }
Пример #25
0
        /// <summary>
        /// 获取审批详细信息
        /// </summary>
        /// <param name="paytask"></param>
        /// <returns></returns>
        public List <ApprovalInfo> GenerateApprovalInfo(List <BsonDocument> taskList)
        {
            DataOperation dataOp = new DataOperation();
            var           list   = new List <ApprovalInfo>();

            if (taskList.Count() == 0)
            {
                return(list);
            }
            foreach (var payTask in taskList)
            {
                ApprovalInfo info = new ApprovalInfo();
                info.BaseInfo   = new BaseInfo();
                info.Extentions = new List <ExtensionInfo>();
                info.Log        = new List <ApprovalLog>();
                var instance = dataOp.FindOneByQuery("BusFlowInstance",
                                                     Query.And(
                                                         Query.EQ("tableName", "XH_DesignManage_Task"),
                                                         Query.EQ("referFieldName", "taskId"),
                                                         Query.EQ("referFieldValue", payTask.Text("taskId"))
                                                         )
                                                     );
                if (instance == null)
                {
                    continue;
                }
                var parentTask = dataOp.FindOneByQuery("XH_DesignManage_Task", Query.EQ("taskId", payTask.Text("nodePid")));

                #region 设置基本属性
                //获取任务名称
                if (string.IsNullOrEmpty(payTask.Text("paymentDisplayName")))
                {
                    info.BaseInfo.Name = payTask.Text("name");
                }
                else
                {
                    info.BaseInfo.Name = payTask.Text("paymentDisplayName");
                }
                if (parentTask != null && parentTask.Int("nodeTypeId") == (int)ConcernNodeType.FeePayment)
                {
                    var childTasks = dataOp.FindAllByQuery("XH_DesignManage_Task", Query.EQ("nodePid", parentTask.Text("taskId"))).OrderBy(p => p.Int("nodeOrder")).ToList();
                    var index      = childTasks.IndexOf(payTask) + 1;
                    info.BaseInfo.Name = string.Format("{0}第{1}笔支付", parentTask.Text("name"), index);
                }
                var appUser = dataOp.FindOneByQuery("SysUser", Query.EQ("userId", instance.Text("approvalUserId")));
                if (appUser != null)
                {
                    info.BaseInfo.AppUser = appUser.Text("name");
                }
                //获取流程发起人公司部门信息
                string       approvalUserId = instance.String("approvalUserId");
                BsonDocument userOrgPost    = dataOp.FindOneByQuery("UserOrgPost", Query.EQ("userId", approvalUserId));
                BsonDocument orgPost        = dataOp.FindOneByQuery("OrgPost", Query.EQ("postId", userOrgPost.String("postId")));
                BsonDocument org            = dataOp.FindOneByQuery("Organization", Query.EQ("orgId", orgPost.String("orgId")));
                info.BaseInfo.Org            = org.Text("name");
                info.BaseInfo.StartTime      = instance.ShortDate("createDate");
                info.BaseInfo.ProjectName    = instance.String("projName");
                info.BaseInfo.ProfType       = instance.Text("profType");
                info.BaseInfo.ProjectScale   = instance.Text("projScale");
                info.BaseInfo.ApprovedAmount = instance.Text("approvedAmount");
                //获取总部经办人
                List <BsonDocument> userRels = dataOp.FindAllByQuery("FlowInstanceUserRel", Query.EQ("instanceId", instance.Text("flowInstanceId"))).ToList();
                List <string>       userIds  = userRels.Select(s => s.String("userId")).ToList();
                List <BsonDocument> users    = dataOp.FindAllByQuery("SysUser", Query.In("userId", TypeConvert.StringListToBsonValueList(userIds))).ToList();
                info.BaseInfo.Transactor = string.Join(",", users.Select(p => p.Text("name")));
                #endregion

                #region 设置扩展属性
                //获取流程的扩展属性
                List <string>       attrIds = dataOp.FindAllByQuery("ExtensionAttrRel", Query.EQ("flowId", instance.Text("flowId"))).Select(s => s.String("attrId")).ToList();
                List <BsonDocument> attrs   = dataOp.FindAllByQuery("ExtensionAttr", Query.In("attrId", TypeConvert.StringListToBsonValueList(attrIds))).ToList();
                foreach (var attr in attrs)
                {
                    ExtensionInfo extInfo = new ExtensionInfo();
                    string        attrId  = attr.String("attrId");//扩展属性Id
                    BsonElement   element = instance.Elements.Where(s => s.Name == attrId).SingleOrDefault();
                    BsonValue     val     = null;
                    if (element != null)
                    {
                        val = element.Value;
                        extInfo.AttrName  = attr.Text("name");
                        extInfo.AttrValue = val.ToString();
                        info.Extentions.Add(extInfo);
                    }
                }
                #endregion

                #region 设置审批记录
                var queryStr       = string.Format("flowInstanceId={0}", instance.Text("flowInstanceId"));
                var logList        = dataOp.FindAllByQueryStr("BusFlowTrace", queryStr).Where(c => c.Int("traceType") == 2 || c.Int("traceType") == 6).ToList();
                var stepUserIdList = new List <int>();
                //判断流程是否已经发起

                var hitAllUser   = string.Empty;
                var hitShortUser = string.Empty;

                foreach (var log in logList)
                {
                    var AllUserString   = new List <string>();
                    var ShortUserString = new List <string>();
                    var action          = log.SourceBson("actId");
                    var form            = log.SourceBson("formId");
                    var content         = form != null?form.Text("content") : string.Empty;

                    var actionTypeName = action != null?action.SourceBsonField("actTypeId", "name") : "系统自动执行";

                    var result = action != null?action.Text("name") : string.Empty;

                    var preStep     = log.SourceBson("preStepId");
                    var preStepName = preStep != null?preStep.SourceBsonField("flowPosId", "name") : string.Empty;

                    var helper           = new Yinhe.ProcessingCenter.BusinessFlow.FlowInstanceHelper();
                    var curFlowInstance1 = log.SourceBson("flowInstanceId");
                    if (curFlowInstance1 != null && log.Int("flowInstanceId") != 0)
                    {
                        stepUserIdList = helper.GetFlowInstanceAvaiableStepUser(curFlowInstance1.Int("flowId"), log.Int("flowInstanceId"), preStep.Int("stepId"));
                    }
                    var userList = dataOp.FindAllByKeyValList("SysUser", "userId", stepUserIdList.Select(c => c.ToString()).ToList());
                    var userStr  = string.Join(",", userList.Select(c => c.Text("name")).ToArray());
                    ShortUserString.Add(StringExtension.CutStr(userStr, 8, "..."));
                    AllUserString.Add(userStr);
                    hitShortUser = string.Join(@"<br>", ShortUserString.ToArray());
                    hitAllUser   = string.Join(@"<br>", AllUserString.ToArray());
                    switch (log.Int("traceType"))
                    {
                    case -1: actionTypeName = "重启流程"; result = "重启流程"; break;

                    case 0: result = "启动流程"; break;

                    case 1: result = "系统自动执行"; break;

                    case 3: actionTypeName = "执行回滚操作"; result = "回滚"; break;

                    case 5: actionTypeName = "废弃流程"; result = "流程结束"; break;

                    case 6: actionTypeName = "转办"; result = log.Text("result"); break;

                    default: break;
                    }
                    ApprovalLog appLog = new ApprovalLog();
                    appLog.Position = !string.IsNullOrEmpty(preStepName) ? preStepName : string.Empty;
                    appLog.UserName = log.CreateUserName();
                    appLog.Time     = log.ShortDate("createDate");
                    appLog.Content  = string.IsNullOrEmpty(content) ? log.Text("remark") : content;
                    appLog.Action   = actionTypeName;
                    appLog.Result   = result;
                    info.Log.Add(appLog);
                }

                #endregion

                list.Add(info);
            }
            return(list);
        }
Пример #26
0
        public void TypeConvert_IntEnumActualNull()
        {
            var value = TypeConvert.ToType("", typeof(StringComparison?));

            Assert.Null(value);
        }
Пример #27
0
        public override AstNode VisitAssign(Assign ast)
        {
            var variable = ResolveVariable(ast.Variable.VariableName);
            ast.Variable.VariableInfo = variable;

            Visit(ast.Value);

            if (variable == null)
            {
                //resolve failed
                return ast;
            }

            //check if assignable
            if (!variable.Type.IsAssignableFrom(ast.Value.ExpressionType))
            {
                m_errorManager.AddError(c_SE_InvalidCast, ast.Variable.VariableName.Span, ast.Value.ExpressionType.Name, variable.Type.Name);
            }

            if (variable.Type != ast.Value.ExpressionType)
            {
                var convert = new TypeConvert(ast.Value, variable.Type);
                ast.Value = convert;
            }

            return ast;
        }
Пример #28
0
        public JsonResult AutoCheckEngAndProjZHHY()
        {
            var          scopetype = PageReq.GetForm("scopetype");
            var          value     = PageReq.GetForm("value");
            InvokeResult result    = new InvokeResult()
            {
                Status = Status.Successful
            };

            #region 获取所有需要自动勾选的角色id
            var          dataTableName = string.Empty;
            var          keyName       = string.Empty;
            BsonDocument projObj       = null;
            BsonDocument engObj        = null;
            BsonDocument comObj        = null;
            switch (scopetype)
            {
            case "eng":
                engObj = dataOp.FindOneByQuery("XH_DesignManage_Engineering", Query.EQ("engId", value));
                comObj = dataOp.FindOneByQuery("DesignManage_Company", Query.EQ("comId", engObj.Text("comId")));
                break;

            case "proj":
                projObj = dataOp.FindOneByQuery("XH_DesignManage_Project", Query.EQ("projId", value));
                engObj  = dataOp.FindOneByQuery("XH_DesignManage_Engineering", Query.EQ("engId", projObj.Text("engId")));
                comObj  = dataOp.FindOneByQuery("DesignManage_Company", Query.EQ("comId", engObj.Text("comId")));
                break;

            default:
                break;
            }
            if (comObj == null || string.IsNullOrEmpty(comObj.Text("comId")))
            {
                result.Status  = Status.Failed;
                result.Message = "未能找到该项目或工程对应的公司";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var dataScopeList = dataOp.FindAllByQuery("DataScope",
                                                      Query.And(
                                                          Query.EQ("dataTableName", "DesignManage_Company"),
                                                          Query.EQ("dataId", comObj.Text("comId"))
                                                          )
                                                      ) as IEnumerable <BsonDocument>;

            var sysRoleList = dataOp.FindAllByQuery("SysRole",
                                                    Query.In("roleId", dataScopeList.Select(p => (BsonValue)p.Text("roleId")))).Select(p => p.Text("roleId"));

            dataScopeList = dataScopeList.Where(p => sysRoleList.Contains(p.Text("roleId")));

            var roleIdList = dataScopeList.Select(p => p.Text("roleId")).Distinct();
            if (roleIdList.Count() == 0)
            {
                result.Status  = Status.Successful;
                result.Message = "没有需要自动勾选的角色";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            #region 插入角色区域权限

            List <StorageData> saveList = new List <StorageData>();
            switch (scopetype)
            {
            case "eng":
                dataOp.Delete("DataScope", Query.And(Query.EQ("dataTableName", "XH_DesignManage_Engineering"), Query.EQ("dataId", value)));

                foreach (var roleId in roleIdList)
                {
                    StorageData tempData = new StorageData();
                    tempData.Name     = "DataScope";
                    tempData.Document = new BsonDocument {
                        { "roleCategoryId", 1 },
                        { "roleId", roleId },
                        { "dataTableName", "XH_DesignManage_Engineering" },
                        { "dataFeiIdName", "" },
                        { "dataId", value },
                        { "status", 0 },
                        { "remark", "地块权限" }
                    };
                    tempData.Type = StorageType.Insert;
                    saveList.Add(tempData);
                }
                break;

            case "proj":
                dataOp.Delete("DataScope", Query.And(Query.EQ("dataTableName", "XH_DesignManage_Project"), Query.EQ("dataId", value)));
                foreach (var roleId in roleIdList)
                {
                    StorageData tempData = new StorageData();
                    tempData.Name     = "DataScope";
                    tempData.Document = new BsonDocument {
                        { "roleCategoryId", 1 },
                        { "roleId", roleId },
                        { "dataTableName", "XH_DesignManage_Project" },
                        { "dataFeiIdName", "" },
                        { "dataId", value },
                        { "status", 0 },
                        { "remark", "项目权限" }
                    };
                    tempData.Type = StorageType.Insert;
                    saveList.Add(tempData);
                }
                break;

            default:
                break;
            }
            result = dataOp.BatchSaveStorageData(saveList);
            return(Json(TypeConvert.InvokeResultToPageJson(result)));

            #endregion
        }
Пример #29
0
        public void SetPropertyValue <T>(int propType, T value)
        {
            string textValue = (string)TypeConvert.ChangeType <string>(value);

            SetPropertyValue(propType, textValue);
        }
Пример #30
0
        /// <summary>
        /// 根据开房方式获取预离时间,同时绑定钟点房方案id或时段房方案id
        /// 20190828同时绑定价格
        /// </summary>
        /// <returns></returns>
        public string GetYlTimeByKffs(long roomRegId, int type, int rzDays, long fnid = 0, long roomId = 0)
        {
            var roomReg = RoomRegBll.GetById(roomRegId);
            var now     = DateTime.Now;

            if (roomReg != null)
            {
                now = TypeConvert.IntToDateTime(roomReg.RegTime);
            }

            var room     = RoomBll.GetById(roomId);
            var roomType = RoomTypeBll.GetById(room.RoomTypeId);

            if (type == (int)KaifangFangshiEnum.全天房 || type == (int)KaifangFangshiEnum.长包房 || type == (int)KaifangFangshiEnum.免费房)
            {
                var globalFeeSet = GlobalFeeSetBll.GetByHotelId(UserContext.CurrentUser.HotelId);
                if (globalFeeSet == null)
                {
                    return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = "" }));
                }

                var yltime = now;
                //如果是6点,那么当天6点之后开的房间就是第二天中午退房,0点到6点开房就是当天中午退房
                if (now.Hour >= 0 && now.Hour <= globalFeeSet.QTAfterPointToNextDay)
                {
                    //当天中午退房
                    yltime = now.Date.AddDays(rzDays - 1).AddHours(globalFeeSet.QTExitPoint);
                }
                else
                {
                    //第二天中午退房
                    yltime = now.Date.AddDays(1 + (rzDays - 1)).AddHours(globalFeeSet.QTExitPoint);
                }

                if (type != (int)KaifangFangshiEnum.免费房)
                {
                    return(JsonConvert.SerializeObject(new {
                        Ret = 0,
                        CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"),
                        YlTime = yltime.ToString("yyyy-MM-dd HH:mm:ss"),
                        RoomPrice = roomType.Price
                    }));
                }

                return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = yltime.ToString("yyyy-MM-dd HH:mm:ss") }));
            }
            else if (type == (int)KaifangFangshiEnum.钟点房)
            {
                //钟点房
                var hourRoomList = HourRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (hourRoomList == null || hourRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无钟点房方案" }));
                }
                var hourRoom = hourRoomList[0];//默认选择第一个
                if (fnid != 0 && hourRoomList.Any(a => a.Id == fnid))
                {
                    hourRoom = hourRoomList.FirstOrDefault(a => a.Id == fnid);
                }
                var yltime = now.AddMinutes(hourRoom.Minute).ToString("yyyy-MM-dd HH:mm:ss");


                return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = yltime, Id = hourRoom.Id, RoomPrice = hourRoom.Price }));
            }
            else if (type == (int)KaifangFangshiEnum.时段房)
            {
                //时段房
                var periodRoomList = PeriodRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (periodRoomList == null || periodRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无时段房方案" }));
                }

                if (fnid != 0 && periodRoomList.Any(a => a.Id == fnid))
                {
                    var periodRoom  = periodRoomList.FirstOrDefault(a => a.Id == fnid);
                    var CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                    var YlTime      = now.ToShortDateString() + $" {periodRoom.EndPoint}:00:00";
                    return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = CurrentTime, YlTime = YlTime, Id = periodRoom.Id, RoomPrice = periodRoom.Price }));
                }
                else
                {
                    foreach (var periodRoom in periodRoomList)
                    {
                        if (now.Hour >= periodRoom.StartPoint && now.Hour <= periodRoom.EndPoint)
                        {
                            var CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                            var YlTime      = now.ToShortDateString() + $" {periodRoom.EndPoint}:00:00";
                            return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = CurrentTime, YlTime = YlTime, Id = periodRoom.Id, RoomPrice = periodRoom.Price }));
                        }
                    }
                }

                return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无匹配的时段房方案,请手动选择" }));
            }
            return("");
        }
Пример #31
0
        public override AstNode VisitTypeConvert(TypeConvert ast)
        {
            Visit(ast.Source);

            var targetType = GetClrType(ast.ExpressionType);

            m_ilgen.Emit(OpCodes.Castclass, targetType);

            return ast;
        }
Пример #32
0
 public override void SqlSearchClause(InlineQueryDBManager oQuery)
 {
     TypeConvert.AppendParameter(oQuery, txtNAME.Text, 50, CommonTypeConvert.SqlFilterMode.StartsWith, "NAME");
 }