Esempio n. 1
0
        /// <summary>
        /// 根据指定条件,从数据库中删除指定对象
        /// </summary>
        /// <param name="condition">删除记录的条件语句</param>
        /// <param name="trans">事务对象</param>
        /// <param name="paramList">Sql参数列表</param>
        /// <param name="trans">事务对象</param>
        /// <returns>执行成功返回<c>true</c>,否则为<c>false</c>。</returns>
        public virtual bool DeleteByCondition(string condition, DbTransaction trans = null, IDbDataParameter[] paramList = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            string sql = string.Format("DELETE FROM {0} WHERE {1} ", tableName, condition);

            Database  db      = CreateDatabase();
            DbCommand command = db.GetSqlStringCommand(sql);

            if (paramList != null)
            {
                command.Parameters.AddRange(paramList);
            }

            bool result = false;

            if (trans != null)
            {
                result = db.ExecuteNonQuery(command, trans) > 0;
            }
            else
            {
                result = db.ExecuteNonQuery(command) > 0;
            }

            return(result);
        }
Esempio n. 2
0
        public override bool Delete(object key)
        {
            FileUploadInfo info = this.FindByID(key);

            if ((info != null) && !string.IsNullOrEmpty(info.SavePath))
            {
                string path = Path.Combine(info.BasePath, info.SavePath.Trim(new char[] { '\\' }));
                if (!Path.IsPathRooted(path))
                {
                    path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
                    if (File.Exists(path))
                    {
                        try
                        {
                            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Combine(info.BasePath, "DeletedFiles"));
                            DirectoryUtil.AssertDirExist(filePath);
                            string str3 = Path.Combine(filePath, info.FileName);
                            str3 = this.method_1(str3, 1);
                            File.Move(path, str3);
                        }
                        catch (Exception exception)
                        {
                            LogTextHelper.Error(exception);
                        }
                    }
                }
            }
            return(base.Delete(key));
        }
Esempio n. 3
0
        /// <summary>
        /// 新增状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveAddNew()
        {
            生产数据表Info info = tempInfo;//必须使用存在的局部变量,因为部分信息可能被附件使用

            SetInfo(info);

            try
            {
                #region 新增数据

                bool succeed = BLLFactory <生产数据表> .Instance.Insert(info);

                if (succeed)
                {
                    //可添加其他关联操作

                    return(true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// 覆盖基类控制器的异常处理
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.Exception is MyDenyAccessException)
            {
                base.OnException(filterContext);

                //自定义非授权的异常处理,可记录用户操作

                // 当自定义显示错误 mode = On,显示友好错误页面
                if (filterContext.HttpContext.IsCustomErrorEnabled)
                {
                    filterContext.ExceptionHandled = true;
                    this.View("Error").ExecuteResult(this.ControllerContext);
                    Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                }
            }
            else
            {
                base.OnException(filterContext);
                LogTextHelper.Error(filterContext.Exception);//错误记录

                // 当自定义显示错误 mode = On,显示友好错误页面
                if (filterContext.HttpContext.IsCustomErrorEnabled)
                {
                    filterContext.ExceptionHandled = true;
                    this.View("Error").ExecuteResult(this.ControllerContext);
                    //Response.StatusCode = (int)HttpStatusCode.BadRequest;
                }
            }
        }
        /// <summary>
        /// 加载插件窗体
        /// </summary>
        private void LoadPlugInForm(string typeName)
        {
            try
            {
                string[] itemArray = typeName.Split(new char[] { ',', ';' });

                string type     = itemArray[0].Trim();
                string filePath = itemArray[1].Trim();//必须是相对路径

                //判断是否配置了显示模式,默认窗体为Show非模式显示
                string showDialog   = (itemArray.Length > 2) ? itemArray[2].ToLower() : "";
                bool   isShowDialog = (showDialog == "1") || (showDialog == "dialog");

                string   dllFullPath  = Path.Combine(Application.StartupPath, filePath);
                Assembly tempAssembly = System.Reflection.Assembly.LoadFrom(dllFullPath);
                if (tempAssembly != null)
                {
                    Type objType = tempAssembly.GetType(type);
                    if (objType != null)
                    {
                        LoadMdiForm(this.mainForm, objType, isShowDialog);
                    }
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(string.Format("加载模块【{0}】失败,请检查书写是否正确。", typeName), ex);
            }
        }
Esempio n. 6
0
        private void ViewData()
        {
            if (this.txtFilePath.Text == "")
            {
                MessageDxUtil.ShowTips("请选择指定的Excel文件");
                return;
            }

            string connectString = string.Format(connectionStringFormat, this.txtFilePath.Text);
            string firstSheet    = "数据库主表" + "$";// ExcelHelper.GetExcelFirstTableName(connectString);

            try
            {
                myDs.Tables.Clear();
                myDs.Clear();
                OleDbConnection  cnnxls = new OleDbConnection(connectString);
                OleDbDataAdapter myDa   = new OleDbDataAdapter(string.Format("select * from [{0}]", firstSheet), cnnxls);
                myDa.Fill(myDs, "c");

                gridControl1.DataSource = myDs.Tables[0];
                this.gridView1.PopulateColumns();
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }
Esempio n. 7
0
        public ActionResult Insert_Server(DbServiceReference.PriceType info)
        {
            //检查用户是否有权限,否则抛出MyDenyAccessException异常
            base.CheckAuthorized(AuthorizeKey.InsertKey);
            CommonResult result = new CommonResult();

            try
            {
                var endcode = Session["EndCode"] ?? "0";
                //调用后台服务获取集中器信息
                DbServiceReference.ServiceDbClient DbServer = new DbServiceReference.ServiceDbClient();
                var flag = DbServer.PriceType_Ins(endcode.ToString().ToInt32(), info);
                if (flag == "0")
                {
                    result.Success = true;
                }
                else
                {
                    result.ErrorMessage = flag;
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);//错误记录
            }
            return(ToJsonContent(result));
        }
Esempio n. 8
0
        protected override CommonResult Update(string id, YH_DeviceInfoInfo info)
        {
            CommonResult result = new CommonResult();

            try
            {
                OnBeforeUpdate(info);

                //非当前记录不能重复设备ID
                var exist = baseBLL.IsExistRecord(string.Format("Deviceid='{0}' AND ID <> '{1}'", info.DeviceId, info.ID));
                if (exist)
                {
                    result.ErrorMessage = "仪器编号已存在!";
                }
                else
                {
                    result.Success = baseBLL.Update(info, id);
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);//错误记录
                result.ErrorMessage = ex.Message;
            }

            return(result);
        }
Esempio n. 9
0
        public override bool OnApply()
        {
            bool result = false;

            try
            {
                LoginParameter parameter = settings.GetSettings <LoginParameter>();
                if (parameter != null)
                {
                    parameter.LoginId          = this.txtLoginId.Text;
                    parameter.Password         = this.txtPassword.Text;
                    parameter.RememberPassword = this.chkRememberPasssword.Checked;
                    parameter.InternalWcfPort  = Convert.ToInt32(this.txtInternalPort.Value);
                    parameter.InternalWcfHost  = this.txtInternalHost.Text;
                    parameter.ExternalWcfPort  = Convert.ToInt32(this.txtExternalPort.Value);
                    parameter.ExternalWcfHost  = this.txtExternalHost.Text;
                    parameter.IsLocalDatabase  = this.txtUseLocalType.Checked;
                    parameter.WcfMode          = this.txtUseLocalType.Checked?"": this.rdgWCFMode.EditValue.ToString();
                    settings.SaveSettings <LoginParameter>(parameter);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }

            return(result);
        }
Esempio n. 10
0
        private void menu_ClearData_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = this.treeView1.SelectedNode;

            if (selectedNode != null && selectedNode.Tag != null)
            {
                string typeId = selectedNode.Tag.ToString();
                int    count  = BLLFactory <DictData> .Instance.GetDictByTypeID(typeId).Count;

                var format = "您确定要删除节点:{0},该节点下面有【{1}】项数据";
                format = JsonLanguage.Default.GetString(format);
                string message = string.Format(format, selectedNode.Text, count);

                if (MessageDxUtil.ShowYesNoAndWarning(message) == DialogResult.Yes)
                {
                    try
                    {
                        BLLFactory <DictData> .Instance.DeleteByCondition(string.Format("DictType_ID='{0}'", typeId));

                        InitTreeView();
                        BindData();
                    }
                    catch (Exception ex)
                    {
                        LogTextHelper.Error(ex);
                        MessageDxUtil.ShowError(ex.Message);
                    }
                }
            }
        }
Esempio n. 11
0
        public override ActionResult Insert(YH_DeviceInfoInfo info)
        {
            //检查用户是否有权限,否则抛出MyDenyAccessException异常
            base.CheckAuthorized(AuthorizeKey.InsertKey);

            CommonResult result = new CommonResult();

            if (info != null)
            {
                try
                {
                    OnBeforeInsert(info);

                    var exist = baseBLL.IsExistRecord(string.Format("Deviceid='{0}'", info.DeviceId));
                    if (exist)
                    {
                        result.ErrorMessage = "仪器编号已存在!";
                    }
                    else
                    {
                        result.Success = baseBLL.Insert(info);
                    }
                }
                catch (Exception ex)
                {
                    LogTextHelper.Error(ex);//错误记录
                    result.ErrorMessage = ex.Message;
                }
            }
            return(ToJsonContent(result));
        }
Esempio n. 12
0
        bool drager_ProcessDragNode(TreeNode dragNode, TreeNode dropNode)
        {
            if (dragNode != null && dragNode.Text == "数据字典管理")
            {
                return(false);
            }

            if (dropNode != null && dropNode.Tag != null)
            {
                string dropTypeId = dropNode.Tag.ToString();
                string dragTypeId = dragNode.Tag.ToString();
                //MessageDxUtil.ShowTips(string.Format("dropTypeId:{0} dragTypeId:{1}", dropTypeId, drageTypeId));

                try
                {
                    DictTypeInfo dragTypeInfo = BLLFactory <DictType> .Instance.FindByID(dragTypeId);

                    if (dragTypeInfo != null)
                    {
                        dragTypeInfo.PID = dropTypeId;
                        BLLFactory <DictType> .Instance.Update(dragTypeInfo, dragTypeInfo.ID);
                    }
                }
                catch (Exception ex)
                {
                    LogTextHelper.Error(ex);
                    MessageDxUtil.ShowError(ex.Message);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 13
0
        /// <summary>
        /// 删除订单及订单明细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteOrderRelated(string id)
        {
            bool          result = false;
            DbTransaction trans  = CreateTransaction();

            if (trans != null)
            {
                SellInfo info = baseDal.FindByID(id, trans);
                if (info != null)
                {
                    List <OrderDetailInfo> detailList = BLLFactory <OrderDetail> .Instance.FindByOrderNo(info.OrderNo, trans);

                    foreach (OrderDetailInfo detailInfo in detailList)
                    {
                        BLLFactory <OrderDetail> .Instance.Delete(detailInfo.ID, trans);
                    }

                    //最后删除主表订单数据
                    baseDal.Delete(id, trans);

                    try
                    {
                        trans.Commit();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        LogTextHelper.Error(ex);
                        throw;
                    }
                }
            }
            return(result);
        }
Esempio n. 14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ID))
            {
                StockInfo info = BLLFactory <Stock> .Instance.FindByID(ID);

                if (info != null)
                {
                    SetInfo(info);

                    try
                    {
                        bool succeed = BLLFactory <Stock> .Instance.Update(info, info.ID.ToString());

                        if (succeed)
                        {
                            MessageDxUtil.ShowTips("保存成功");
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                    catch (Exception ex)
                    {
                        LogTextHelper.Error(ex);
                        MessageDxUtil.ShowError(ex.Message);
                    }
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 新增状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveAddNew()
        {
            UserInfo info = tempInfo;//必须使用存在的局部变量,因为部分信息可能被附件使用

            SetInfo(info);
            info.Creator    = Portal.gc.UserInfo.FullName;
            info.Creator_ID = Portal.gc.UserInfo.ID.ToString();
            info.CreateTime = DateTime.Now;

            try
            {
                #region 新增数据

                bool succeed = BLLFactory <User> .Instance.Insert(info);

                if (succeed)
                {
                    //可添加其他关联操作

                    return(true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
            return(false);
        }
Esempio n. 16
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            tempInfo.DistrictName = this.txtDistrict.Text;
            tempInfo.CityID       = Convert.ToInt32(this.txtCity.Tag.ToString());

            try
            {
                bool succeed = false;
                if (string.IsNullOrEmpty(ID))
                {
                    succeed = BLLFactory <District> .Instance.Insert(tempInfo);
                }
                else
                {
                    succeed = BLLFactory <District> .Instance.Update(tempInfo, tempInfo.ID);
                }

                ProcessDataSaved(this.btnOK, new EventArgs());
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 获取附件组的图片http、https地址
        /// </summary>
        /// <param name="guid">图片附件GUID</param>
        /// <returns></returns>
        public ActionResult GetUrls(string guid)
        {
            List <string> urls   = new List <string>();
            var           result = new CommonResult();

            try
            {
                var list = BLLFactory <FileUpload> .Instance.GetByAttachGUID(guid);

                if (list != null)
                {
                    result.Success = true;
                    foreach (var info in list)
                    {
                        var links = GetFileUrlList(info);
                        urls.AddRange(links);
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMessage = ex.Message;
                LogTextHelper.Error(ex);
            }

            var newResult = new { Success = result.Success, ErrorMessage = result.ErrorMessage, urls = urls };

            return(ToJsonContent(newResult));
        }
Esempio n. 18
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="inputStream">流对象</param>
        /// <param name="fileName">保存文件名,可包含文件夹(test/test.txt)</param>
        /// <returns>bool[true:成功,false:失败]</returns>
        public bool UploadFile(Stream inputStream, string fileName)
        {
            if (inputStream == null || string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            WebClient client = new WebClient();

            client.Credentials = this.myCredentialCache;
            int length = (int)inputStream.Length;

            byte[] buffer = new byte[length];
            inputStream.Read(buffer, 0, length);

            try
            {
                string urlFile = GetUrlFile(this.URL, fileName);
                using (Stream stream = client.OpenWrite(urlFile, "PUT"))
                {
                    stream.Write(buffer, 0, length);
                }
            }
            catch (WebException ex)
            {
                LogTextHelper.Error(ex);
                return(false);
            }
            return(true);
        }
Esempio n. 19
0
        /// <summary>
        /// 查看Excel文件并显示在界面上操作
        /// </summary>
        private void ViewData()
        {
            if (this.txtFilePath.Text == "")
            {
                MessageDxUtil.ShowTips("请选择指定的Excel文件");
                return;
            }

            try
            {
                myDs.Tables.Clear();
                myDs.Clear();
                this.gridControl1.DataSource = null;

                string error = "";
                AsposeExcelTools.ExcelFileToDataSet(this.txtFilePath.Text, out myDs, out error);
                this.gridControl1.DataSource = myDs.Tables[0];
                this.gridView1.PopulateColumns();
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }
        }
Esempio n. 20
0
 public void AddLoginLog(UserInfo info, string systemType, string ip, string macAddr, string note)
 {
     if (info != null)
     {
         try
         {
             LoginLogInfo info2 = new LoginLogInfo {
                 IPAddress     = ip,
                 MacAddress    = macAddr,
                 LastUpdated   = DateTime.Now,
                 Note          = note,
                 SystemType_ID = systemType,
                 User_ID       = info.ID.ToString(),
                 FullName      = info.FullName,
                 LoginName     = info.Name,
                 Company_ID    = info.Company_ID,
                 CompanyName   = info.CompanyName
             };
             BLLFactory <LoginLog> .Instance.Insert(info2);
         }
         catch (Exception exception)
         {
             LogTextHelper.Error(exception);
         }
     }
 }
Esempio n. 21
0
        public ActionResult Update_Server(DbServiceReference.PriceType info)
        {
            //检查用户是否有权限,否则抛出MyDenyAccessException异常
            base.CheckAuthorized(AuthorizeKey.UpdateKey);
            CommonResult result = new CommonResult();

            try
            {
                //调用后台服务获取集中器信息
                DbServiceReference.ServiceDbClient DbServer = new DbServiceReference.ServiceDbClient();
                var flag = DbServer.PriceType_Upd(info);
                if (flag == "0")
                {
                    result.Success = true;
                }
                else
                {
                    result.ErrorMessage = flag;
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);//错误记录
                result.ErrorMessage = ex.Message;
            }
            return(ToJsonContent(result));
        }
Esempio n. 22
0
        /// <summary>
        /// 记录用户操作日志
        /// </summary>
        /// <param name="info">用户信息</param>
        /// <param name="systemType">系统类型ID</param>
        /// <param name="ip">IP地址</param>
        /// <param name="macAddr">Mac地址</param>
        /// <param name="note">备注说明</param>
        public void AddLoginLog(User info, string systemType, string ip, string macAddr, string note)
        {
            if (info == null)
            {
                return;
            }

            #region 记录用户登录操作
            try
            {
                LoginLog logInfo = new LoginLog();
                logInfo.IPAddress    = ip;
                logInfo.MacAddress   = macAddr;
                logInfo.LastUpdated  = DateTime.Now;
                logInfo.Note         = note;
                logInfo.SystemTypeID = systemType;

                logInfo.UserID      = info.ID.ToString();
                logInfo.FullName    = info.FullName;
                logInfo.LoginName   = info.Name;
                logInfo.CompanyID   = info.CompanyID;
                logInfo.CompanyName = info.CompanyName;

                BLLFactory <LoginLogBLL> .Instance.Insert(logInfo);
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
            }
            #endregion
        }
Esempio n. 23
0
        /// <summary>
        /// 初始化模板引擎
        /// </summary>
        protected virtual void InitTemplateEngine()
        {
            try
            {
                //Velocity.Init(NVELOCITY_PROPERTY);
                VelocityEngine templateEngine = new VelocityEngine();
                templateEngine.SetProperty(RuntimeConstants.RESOURCE_LOADER, "file");

                templateEngine.SetProperty(RuntimeConstants.INPUT_ENCODING, "utf-8");
                templateEngine.SetProperty(RuntimeConstants.OUTPUT_ENCODING, "utf-8");

                //如果设置了FILE_RESOURCE_LOADER_PATH属性,那么模板文件的基础路径就是基于这个设置的目录,否则默认当前运行目录
                templateEngine.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, AppDomain.CurrentDomain.BaseDirectory);

                templateEngine.Init();

                template = templateEngine.GetTemplate(templateFile);
            }
            catch (ResourceNotFoundException re)
            {
                string error = string.Format("Cannot find template " + templateFile);

                LogTextHelper.Error(error);
                throw new Exception(error, re);
            }
            catch (ParseErrorException pee)
            {
                string error = string.Format("Syntax error in template " + templateFile + ":" + pee.StackTrace);
                LogTextHelper.Error(error);
                throw new Exception(error, pee);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 删除指定的ID记录,如果是相对目录的文件则移除文件到DeletedFiles文件夹里面
        /// </summary>
        /// <param name="key">记录ID</param>
        /// <returns></returns>
        public override bool Delete(object key, DbTransaction trans = null)
        {
            //删除记录前,需要把文件移动到删除目录下面
            FileUploadInfo info = FindByID(key, trans);

            if (info != null && !string.IsNullOrEmpty(info.SavePath))
            {
                string serverRealPath = Path.Combine(info.BasePath, info.SavePath.Trim('\\'));
                if (!Path.IsPathRooted(serverRealPath))
                {
                    //如果是相对目录,加上当前程序的目录才能定位文件地址
                    serverRealPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, serverRealPath);

                    //如果是相对目录的,移动到删除目录里面
                    if (File.Exists(serverRealPath))
                    {
                        try
                        {
                            string deletedPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, Path.Combine(info.BasePath, "DeletedFiles"));
                            DirectoryUtil.AssertDirExist(deletedPath);

                            string newFilePath = Path.Combine(deletedPath, info.FileName);
                            newFilePath = GetRightFileName(newFilePath, 1);
                            File.Move(serverRealPath, newFilePath);
                        }
                        catch (Exception ex)
                        {
                            LogTextHelper.Error(ex);
                        }
                    }
                }
            }

            return(base.Delete(key, trans));
        }
Esempio n. 25
0
        public override bool OnApply()
        {
            bool result = false;

            try
            {
                ReportParameter parameter = settings.GetSettings <ReportParameter>();
                if (parameter != null)
                {
                    int otherType = 2;//2代表其他类型
                    if (this.radReport.SelectedIndex < otherType)
                    {
                        parameter.CarSendReportFile = this.radReport.Properties.Items[this.radReport.SelectedIndex].Value.ToString();
                    }
                    else
                    {
                        parameter.CarSendReportFile = this.txtOtherReport.Text;
                    }
                    settings.SaveSettings <ReportParameter>(parameter);
                }
                result = true;
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);
                MessageDxUtil.ShowError(ex.Message);
            }

            return(result);
        }
Esempio n. 26
0
        public bool UploadFile(Stream inputStream, string fileName)
        {
            if ((inputStream == null) || string.IsNullOrEmpty(fileName))
            {
                return(false);
            }
            WebClient client = new WebClient {
                Credentials = this.credentialCache_0
            };
            int length = (int)inputStream.Length;

            byte[] buffer = new byte[length];
            inputStream.Read(buffer, 0, length);
            try
            {
                string address = this.method_0(this.string_0, fileName);
                using (Stream stream = client.OpenWrite(address, "PUT"))
                {
                    stream.Write(buffer, 0, length);
                }
            }
            catch (WebException exception)
            {
                LogTextHelper.Error(exception);
                return(false);
            }
            return(true);
        }
Esempio n. 27
0
        public ActionResult InsOrUpd_Server(DbServiceReference.SmsTemplate info)
        {
            CommonResult result = new CommonResult();

            try
            {
                DbServiceReference.ServiceDbClient DbServer = new DbServiceReference.ServiceDbClient();
                var flag = DbServer.SMS_Template_InsOrUpd(info);
                info.DtLstUpd = DateTime.Now;
                if (flag == "0")
                {
                    result.Success = true;
                }
                else
                {
                    result.ErrorMessage = flag;
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);//错误记录
                result.ErrorMessage = ex.Message;
            }
            return(ToJsonContent(result));
        }
Esempio n. 28
0
        /// <summary>
        /// 删除多个ID的记录
        /// </summary>
        /// <param name="ids">多个id组合,逗号分开(1,2,3,4,5)</param>
        /// <returns></returns>
        public virtual ActionResult DeleteByIds(string ids)
        {
            //检查用户是否有权限,否则抛出MyDenyAccessException异常
            base.CheckAuthorized(AuthorizeKey.DeleteKey);

            CommonResult result = new CommonResult();

            try
            {
                if (!string.IsNullOrEmpty(ids))
                {
                    OnBeforeDelete();
                    List <string> idArray = ids.ToDelimitedList <string>(",");
                    foreach (string strId in idArray)
                    {
                        if (!string.IsNullOrEmpty(strId))
                        {
                            baseBLL.Delete(strId);
                        }
                    }
                    result.Success = true;
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Error(ex);//错误记录
                result.ErrorMessage = ex.Message;
            }
            return(ToJsonContent(result));
        }
Esempio n. 29
0
        /// <summary>
        /// 编辑状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveUpdated()
        {
            生产数据表Info info = BLLFactory <生产数据表> .Instance.FindByID(ID);

            if (info != null)
            {
                SetInfo(info);

                try
                {
                    #region 更新数据
                    bool succeed = BLLFactory <生产数据表> .Instance.Update(info, info.生产数据id);

                    if (succeed)
                    {
                        //可添加其他关联操作

                        return(true);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    LogTextHelper.Error(ex);
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
            return(false);
        }
Esempio n. 30
0
        public virtual List <T> Find(string condition, string orderBy, IDbDataParameter[] paramList, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Error(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }
            string sql = string.Format("Select {0} From {1}", selectedFields, tableName);

            if (!string.IsNullOrEmpty(condition))
            {
                sql += string.Format(" Where {0} ", condition);
            }
            if (!string.IsNullOrEmpty(orderBy))
            {
                sql += " " + orderBy;
            }
            else
            {
                sql += string.Format(" Order by {0} {1}", GetSafeFileName(sortField), IsDescending?"DESC":"ASC");
            }
            List <T> list = GetList(sql, paramList, trans);

            return(list);
        }