/// <summary>
        ///  验证
        /// </summary>
        /// <param name="codeProjectInfo"></param>
        /// <returns></returns>
        private VerifyMessage VeriyData(CodeProjectTemplateConfigInfo codeProjectTemplateConfigInfo)
        {
            VerifyMessage verifyMessage = new VerifyMessage();

            verifyMessage.ExistError = false;

            string pre      = "新增";
            string whereCon = $" TEMPLATE_NAME='{codeProjectTemplateConfigInfo.TemplateName}'  and PROJECT_ID='{codeProjectTemplateConfigInfo.ProjectId}' ";

            if (codeProjectTemplateConfigInfo.ID > 0)
            {
                whereCon += $" AND ID !='{codeProjectTemplateConfigInfo.ID}' ";
                pre       = "修改";
            }

            List <CodeProjectTemplateConfigInfo> lists = SelectList(codeProjectTemplateConfigInfo, "ID", whereCon, WhereType.SQL);

            if (lists != null && lists.Count > 0)
            {
                verifyMessage.ExistError = true;
                verifyMessage.ErrorInfo  = $"{pre}失败,该模板名称已存在";
            }

            return(verifyMessage);
        }
Example #2
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1);
                codeProjectInfo.ID = this.codeProjectInfo.ID;
                VerifyMessage verifyMessage = VerifyUtil.Verify(codeProjectInfo);
                if (verifyMessage.ExistError)
                {
                    MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                R r = codeProjectInfoBLL.SaveOrUpdateBySelf(codeProjectInfo, null, false);

                if (r.Successful)
                {
                    MessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                    //更新列表页
                    if (this.Owner is CodeProjectList)
                    {
                        ((CodeProjectList)this.Owner).LoadData();
                    }
                }
                else
                {
                    MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                CodeProjectDbConfigInfo saveItem = FormHelp.GetEntityByControls <CodeProjectDbConfigInfo>(this.panel1);
                saveItem.ID        = codeProjectDbConfigInfo.ID;
                saveItem.ProjectId = codeProjectInfo.ID;

                VerifyMessage verifyMessage = VerifyUtil.Verify(saveItem);
                if (verifyMessage.ExistError)
                {
                    MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                R r = codeProjectDbConfigInfoBLL.SaveOrUpdate(saveItem, null, false, null);

                if (r.Successful)
                {
                    string msg = saveItem.ID <= 0 ? "新增" : "修改";
                    MessageBox.Show($"{msg}成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                }
                else
                {
                    MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        /// <summary>
        ///  新增或修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        public R SaveOrUpdate <T>(T t, string cols, bool needReturn, VerifyData <T> @delegateVerify)
        {
            R    result = null;
            Type type   = t.GetType();
            int  count  = 0;

            //获取属性特性【特性里面包括其属性】
            PrimaryKeyAttribute primaryKeyAttribute = type.GetPrimaryKey();

            if (primaryKeyAttribute == null)
            {
                return(new R()
                {
                    Successful = false, ResultHint = "获取主键发生错误"
                });
            }

            //委托方法存在 直接调用  主要是验证是否可以新增或修改
            if (@delegateVerify != null)
            {
                VerifyMessage verifyMessage = @delegateVerify.Invoke(t);
                if (verifyMessage.ExistError)
                {
                    //MessageBox.Show("错误信息:" + verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(new R()
                    {
                        Successful = false, ResultHint = verifyMessage.ErrorInfo
                    });
                }
            }

            object primaryKey = primaryKeyAttribute.Prop.GetValue(t);

            //新增 ==》实际是主键不存在
            if (primaryKey == null || "0".Equals(primaryKey.ToString()))
            {
                count = baseDAL.Insert(t, cols, needReturn);

                if (needReturn)
                {
                    primaryKeyAttribute.Prop.SetValue(t, count);//设置主键的值
                }
            }
            else
            {
                //修改
                count = baseDAL.Update(t, cols, null, WhereType.SQL, false);
            }

            result = count > 0 ? new R()
            {
                Successful = true, ResultValue = t
            }:
            new R()
            {
                Successful = false, ResultHint = "操作失败"
            };

            return(result);
        }
Example #5
0
        /// <summary>
        ///  验证
        /// </summary>
        /// <param name="codeProjectInfo"></param>
        /// <returns></returns>
        private VerifyMessage VeriyData(CodeProjectInfo codeProjectInfo)
        {
            VerifyMessage verifyMessage = new VerifyMessage();

            verifyMessage.ExistError = false;

            string pre      = "新增";
            string whereCon = $" PRO_NAME='{codeProjectInfo.PRO_NAME}'";

            if (codeProjectInfo.ID > 0)
            {
                whereCon += $" AND ID !='{codeProjectInfo.ID}' ";
                pre       = "修改";
            }

            List <CodeProjectInfo> lists = SelectList(codeProjectInfo, "PRO_NAME", whereCon, WhereType.SQL);

            if (lists != null && lists.Count > 0)
            {
                verifyMessage.ExistError = true;
                verifyMessage.ErrorInfo  = $"{pre}失败,该项目已存在";
            }

            return(verifyMessage);
        }
Example #6
0
        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="record"></param>
        /// <param name="p1"></param>
        /// <param name="v"></param>
        /// <param name="p2"></param>
        public virtual R SaveList <T>(List <T> list, string cols, bool needReturn, VerifyList <T> @delegateVerify)
        {
            R    result = null;
            Type type   = typeof(T);

            //委托方法存在 直接调用  主要是验证是否可以新增或修改
            if (@delegateVerify != null)
            {
                VerifyMessage verifyMessage = @delegateVerify.Invoke(list);
                if (verifyMessage.ExistError)
                {
                    return(new R()
                    {
                        Successful = false, ResultHint = verifyMessage.ErrorInfo
                    });
                }
            }

            bool addFlag = baseDAL.InsertBatch(list, cols, needReturn);

            if (addFlag)
            {
                return(new R()
                {
                    Successful = true, ResultHint = "操作成功"
                });
            }


            return(new R()
            {
                Successful = false, ResultHint = "操作失败"
            });
        }
Example #7
0
        /// <summary>
        ///  批量修改
        /// </summary>
        /// <param name="updateList"></param>
        /// <param name="p1"></param>
        /// <param name="v"></param>
        /// <param name="p2"></param>
        public virtual R UpdateList <T>(List <T> list, string cols, string whereStr, WhereType whereType, VerifyList <T> @delegateVerify)
        {
            R    result = null;
            Type type   = typeof(T);

            //委托方法存在 直接调用  主要是验证是否可以新增或修改
            if (@delegateVerify != null)
            {
                VerifyMessage verifyMessage = @delegateVerify.Invoke(list);
                if (verifyMessage.ExistError)
                {
                    return(new R()
                    {
                        Successful = false, ResultHint = verifyMessage.ErrorInfo
                    });
                }
            }

            bool updateFlag = baseDAL.UpdateBatch(list, cols, whereStr, whereType);

            if (updateFlag)
            {
                return(new R()
                {
                    Successful = true, ResultHint = "操作成功"
                });
            }
            return(new R()
            {
                Successful = false, ResultHint = "操作失败"
            });
        }
Example #8
0
        /// <summary>
        ///  验证
        /// </summary>
        /// <param name="codeProjectInfo"></param>
        /// <returns></returns>
        private VerifyMessage VeriyData(AppAccountMgn saveItem)
        {
            VerifyMessage verifyMessage = new VerifyMessage();

            verifyMessage.ExistError = false;

            string pre      = "新增";
            string whereCon = $" SOURCE='{saveItem.SOURCE}'  and ACCOUNT='{saveItem.ACCOUNT}'";

            if (saveItem.ID > 0)
            {
                whereCon += $" AND ID !='{saveItem.ID}' ";
                pre       = "修改";
            }

            List <AppAccountMgn> lists = SelectList(saveItem, "ID", whereCon, WhereType.SQL);

            if (lists != null && lists.Count > 0)
            {
                verifyMessage.ExistError = true;
                verifyMessage.ErrorInfo  = $"{pre}失败,该来源的账号已存在";
            }

            return(verifyMessage);
        }
        /// <summary>
        /// Verify a signed message.
        /// </summary>
        /// <param name="address">The bitcoin address to use for the signature.</param>
        /// <param name="signature">The signature provided by the signer in base 64 encoding (see signmessage).</param>
        /// <param name="message">The message that was signed.</param>
        /// <returns></returns>
        public async Task <string> VerifyMessage(string address, string signature, string message)
        {
            VerifyMessage verifyMessage = new VerifyMessage {
                Address = address, Signature = signature, Message = message
            };
            string response = await httpRequest.SendReq(MethodName.verifymessage, verifyMessage);

            return(response);
        }
Example #10
0
        /// <summary>
        /// 生成配置文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1);
                VerifyMessage   verifyMessage   = VerifyUtil.Verify(codeProjectInfo);
                if (verifyMessage.ExistError)
                {
                    MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Type type = codeProjectInfo.GetType();
                System.Reflection.PropertyInfo[] propertyInfos = type.GetProperties();
                StringBuilder sbf = new StringBuilder();
                for (int i = 0; i < propertyInfos.Length; i++)
                {
                    if (propertyInfos[i].Name != "ID")
                    {
                        if (propertyInfos[i].Name == "JAVAFODER" ||
                            propertyInfos[i].Name == "VIEWFOLDER" ||
                            propertyInfos[i].Name == "PRO_SITE")
                        {
                            sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\","\\\\")}\r\n");
                        }
                        else if (propertyInfos[i].Name == "TEMPLATE_FOLDER")
                        {
                            sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\", "\\\\")+"\\\\"}\r\n");
                        }
                        else
                        {
                            sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo)}\r\n");
                        }
                    }
                }
                string configPath = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoConfigPath);
                configPath = Path.Combine(configPath, "basic.properties");
                File.WriteAllText(configPath, sbf.ToString());

                //调用bat命令
                string  targetDir = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoPath);
                Process proc      = new Process();
                proc.StartInfo.WorkingDirectory = targetDir;
                proc.StartInfo.FileName         = "命令.bat";
                proc.StartInfo.Arguments        = string.Format("30");
                //proc.StartInfo.CreateNoWindow = true;
                //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//这里设置DOS窗口不显示,经实践可行
                proc.Start();
                proc.WaitForExit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #11
0
        /// <summary>
        ///  匹配业务的验证
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="businessDiff"></param>
        /// <returns></returns>
        public static VerifyMessage Verify <T>(T t, string businessDiff)
        {
            if (t != null)
            {
                List <T> lists = new List <T>();
                lists.Add(t);
                return(Verify <T>(lists, businessDiff, false, ""));
            }
            VerifyMessage message = new VerifyMessage();

            message.ExistError = false;
            return(message);
        }
Example #12
0
 public ActionResult Login(LogOnModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         VerifyMessage result = VerfiyCodeStatus(model.VerifyCode, Session);
         if (!result.res)
         {
             ModelState.AddModelError("", result.Msg);
             return(View(model));
         }
         if (Membership.ValidateUser(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
             if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                 !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
             {
                 return(Redirect(returnUrl));
             }
             return(RedirectToAction("Index", "Home"));
         }
         ModelState.AddModelError("", "身份证号和密码不匹配");
     }
     return(View(model));
 }
Example #13
0
        /// <summary>
        /// 密码加密
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                AppAccountMgn saveItem = FormHelp.GetEntityByControls <AppAccountMgn>(this.panel1);
                if (!string.IsNullOrEmpty(appAccountMgn.MGNPWD))
                {
                    DialogResult dialogResult = MessageBox.Show("是否以原管理密码保存", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (dialogResult == DialogResult.OK)
                    {
                        saveItem.MGNPWD = appAccountMgn.MGNPWD;
                    }
                }

                VerifyMessage verifyMessage = VerifyUtil.Verify(saveItem);


                if (saveItem.JiaoyanPwd != saveItem.InputPwd)
                {
                    verifyMessage.ExistError = true;
                    verifyMessage.ErrorInfo += "\n两次输入密码不一致,请重新输入";
                }


                if (verifyMessage.ExistError)
                {
                    MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //string iv = saveItem.ACCOUNT.ToString().PadLeft(8, 'u');
                string enc = DesHelper.DESEncrypt(saveItem.InputPwd, key, iv);
                this.ENCPWD.Text = enc;                  //真实密码
                saveItem.ENCPWD  = enc;                  //真实密码

                saveItem.PSEUDOCODE  = Md5Util.Md5(enc); //掩码
                this.PSEUDOCODE.Text = saveItem.PSEUDOCODE;

                R r = appAccountMgnBLL.SaveOrUpdateBySelf(saveItem, null, false);

                if (r.Successful)
                {
                    string msg = saveItem.ID <= 0 ? "新增" : "修改";
                    MessageBox.Show($"{msg}成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();

                    //更新列表页
                    if (this.Owner is AccoutEncFrmList)
                    {
                        ((AccoutEncFrmList)this.Owner).LoadData();
                    }
                    this.Hide();
                    this.Dispose(true);
                }
                else
                {
                    MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowError(ex);
            }
        }
Example #14
0
        /// <summary>
        ///  验证list
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="lists"></param>
        /// <param name="needColum">一般是list的数据 按行提醒</param>
        /// <param name="tipPreffix">提示头</param>
        /// <returns></returns>
        public static VerifyMessage Verify <T>(List <T> lists, string businessDiff, bool needColum, string tipPreffix)
        {
            VerifyMessage message = new VerifyMessage();

            message.ExistError = false;
            try
            {
                string        preffix = "";
                StringBuilder sbf     = new StringBuilder("");

                //仅提示
                StringBuilder onlyPrompt = new StringBuilder("");

                if (lists != null && lists.Count > 0)
                {
                    T entity = Activator.CreateInstance <T>();

                    Type tbc = typeof(T);

                    /*BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static;
                     */

                    PropertyInfo[] propertyInfos = tbc.GetProperties();//获取

                    VerifyAttribute verifyAttr = null;

                    Dictionary <string, PropertyInfo>    dictionAry = new Dictionary <string, PropertyInfo>();
                    Dictionary <string, VerifyAttribute> columnDic  = new Dictionary <string, VerifyAttribute>();

                    string popName = "";

                    for (int p = 0; p < propertyInfos.Length; p++)
                    {
                        verifyAttr = propertyInfos[p].GetCustomAttribute <VerifyAttribute>();
                        if (verifyAttr != null && CheckPattern(verifyAttr.BusinessDiff, businessDiff))
                        {
                            popName = propertyInfos[p].Name.UpperCaseFirst();
                            dictionAry.Add(popName, tbc.GetProperty(popName));
                            columnDic.Add(popName, verifyAttr);
                        }
                    }

                    Dictionary <string, string> columnRepeat = new Dictionary <string, string>();

                    Dictionary <string, PropertyInfo> .KeyCollection keys = dictionAry.Keys;
                    object v = null;

                    VerifyAttribute currentVerify;

                    int    count  = 0;
                    string tipMsg = "";

                    bool onlyAlert = false;//仅提示

                    foreach (T info in lists)
                    {
                        count++;
                        //提示行?
                        preffix = needColum ? $"第{count}行 " : "";

                        foreach (string key in keys)//获得类型的属性字段
                        {
                            v             = dictionAry[key].GetValue(info);
                            currentVerify = columnDic[key];

                            if (currentVerify == null)
                            {
                                break;
                            }
                            tipMsg = (currentVerify.ColumCnm != null && currentVerify.ColumCnm != "") ? currentVerify.ColumCnm : dictionAry[key].Name;

                            onlyAlert = currentVerify.PromptOnly;


                            //非空性验证
                            if (!currentVerify.Nullable && (v == null || v.ToString().Trim() == ""))
                            {
                                message.ExistError = true;
                                if (onlyAlert)
                                {
                                    onlyPrompt.Append(preffix + tipPreffix + tipMsg + "不得为空\n");
                                }
                                else
                                {
                                    sbf.Append(preffix + tipPreffix + tipMsg + "不得为空\n");
                                }
                            }

                            //长度
                            if (currentVerify.MaxLength > 0 && (v != null && v.ToString().Length > currentVerify.MaxLength))
                            {
                                message.ExistError = true;
                                if (onlyAlert)
                                {
                                    onlyPrompt.Append(preffix + tipPreffix + tipMsg + "长度不得超过" + currentVerify.MaxLength + "个字符\n");
                                }
                                else
                                {
                                    sbf.Append(preffix + tipPreffix + tipMsg + "长度不得超过" + currentVerify.MaxLength + "个字符\n");
                                }
                            }

                            //重复性
                            if (currentVerify.Repeat && v != null && !string.IsNullOrWhiteSpace(v.ToString()))
                            {
                                if (columnRepeat.ContainsKey(key + "-||-" + v.ToString()))
                                {
                                    message.ExistError = true;
                                    sbf.Append(preffix + tipPreffix + tipMsg + "存在重复\n");
                                }
                                else
                                {
                                    columnRepeat.Add(key + "-||-" + v.ToString(), "");
                                }
                            }


                            //正则验证部分==> 数据格式验证
                            if (v != null && currentVerify.Pattern != null && currentVerify.Pattern != "" && v.ToString().Trim().Length > 0)
                            {
                                //不匹配正则
                                if (!Regex.IsMatch(v.ToString().Trim(), currentVerify.Pattern))
                                {
                                    message.ExistError = true;
                                    if (onlyAlert)
                                    {
                                        onlyPrompt.Append(preffix + tipPreffix + tipMsg + "格式不正确\n");
                                    }
                                    else
                                    {
                                        sbf.Append(preffix + tipPreffix + tipMsg + "格式不正确\n");
                                    }
                                }
                            }
                        }
                    }
                    message.ErrorInfo  = sbf.ToString();
                    message.PromptInfo = onlyPrompt.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(message);
        }
Example #15
0
        private void txButton1_Click(object sender, EventArgs e)
        {
            try
            {
                OsZbPurchaseProjectInfo projectInfo = FormHelp.GetEntityByControls <OsZbPurchaseProjectInfo>(this.groupBox2);
                osZbPurchaseProjectInfo = osZbPurchaseProjectInfo ?? new OsZbPurchaseProjectInfo();

                ObjectUtil.CopyPop(projectInfo, ref osZbPurchaseProjectInfo, "Id");

                VerifyMessage verifyMessage = VerifyUtil.Verify(osZbPurchaseProjectInfo);

                if (!string.IsNullOrWhiteSpace(verifyMessage.ErrorInfo))
                {
                    MessageBox.Show(verifyMessage.ErrorInfo,
                                    "提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                    return;
                }
                else if (!string.IsNullOrWhiteSpace(verifyMessage.PromptInfo))
                {
                    MessageBox.Show(verifyMessage.PromptInfo,
                                    "提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }


                R result = osZbPurchaseProjectInfoBLL.SaveOrUpdate(osZbPurchaseProjectInfo, null, true, null);

                if (!result.Successful)
                {
                    MessageBox.Show(result.ResultHint,
                                    "提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    MessageBox.Show("操作成功",
                                    "提示",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    if (RefeshParentWindow != null)
                    {
                        RefeshParentWindow.Invoke();
                    }
                    this.Hide();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                log.AddLog(ex.Message, null);

                MessageBox.Show(ex.Message,
                                "提示",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }