Exemplo n.º 1
0
            public static void Test()
            {
                IFactory kit     = new LogFactory();
                IFileLog fileLog = (IFileLog)kit.CreateLog(LogCategory.File);
                IDbLog   dbLog   = (IDbLog)kit.CreateLog(LogCategory.DB);

                fileLog.WriteToFile();
                dbLog.WriteToDb();
            }
Exemplo n.º 2
0
        /// <summary>
        /// 获取目录详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AcademicResources_Menu GetAcademicResourcesMenuDetail(int id)
        {
            AcademicResources_Menu result = null;

            try
            {
                StringBuilder sql = new StringBuilder();

                sql.AppendLine(@"select dam.id,dam.title,dam.parentID,dam.createTime,dam.createUserID
                ,u.userName as createUserName,dam.sourceTypeID,dat.typeName as sourceTypeName,dam.author,lastModifyTime,lastModifyUsrID
                from de2_aresource_menu dam
                LEFT JOIN de2_user u on  u.id=dam.createUserID
                LEFT JOIN de2_aresource_type dat on dat.id=dam.sourceTypeID where dam.id=@id");

                MySqlClient _Client = new MySqlClient();
                result = _Client.ExecuteQuery <AcademicResources_Menu>(sql.ToString(), new MySqlParameter("@id", id)).FirstOrDefault();

                return(result);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "删除目录", "DelResourceMenu", ex);
                return(null);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加收藏
 /// </summary>
 /// <param name="Data"></param>
 /// <returns></returns>
 public bool AddColletion(Collection Data)
 {
     try
     {
         //获取当前用户
         AccountProvider _AccountProvider = new AccountProvider();
         var             user             = _AccountProvider.GetCurrentUser();
         if (user == null || user.id == 0)
         {
             return(false);
         }
         //判断是否已经收藏
         if (IsCollection(Data.aid, user.id))
         {
             return(true);
         }
         Data.createID   = user.id;
         Data.createTime = DateTime.Now;
         string      sql          = "insert into de2_collection(aid,createTime,createID) values(@aid,@createTime,@createID)";
         MySqlClient _MySqlClient = new MySqlClient();
         _MySqlClient.ExecuteNonQuery(sql, new MySqlParameter("@aid", Data.aid),
                                      new MySqlParameter("@createTime", Data.createTime),
                                      new MySqlParameter("@createID", Data.createID));
         return(true);
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "添加收藏", "AddColletion", ex);
         return(false);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取年度计划详情
        /// </summary>
        /// <param name="wid"></param>
        /// <returns></returns>
        public WorkPlan GetWorkPlanDetial(int wid)
        {
            WorkPlan _result = new WorkPlan();

            try
            {
                //获取年度计划详情
                string      sql     = @"  select p.id,`year`,startTime,endTime,p.`name`,content,scale,address,addressCity,addressCityID,
                                addressProvince,addressProvinceID,workPlanTypeID ,t.`Name` workPlanTypeName
                                from de2_workplan as p
                                left join de2_workplantype as t on p.workPlanTypeID=t.id where p.id=@id";
                MySqlClient _Client = new MySqlClient();
                _result = _Client.ExecuteQuery <WorkPlan>(sql, new MySqlParameter("@id", wid)).FirstOrDefault();
                //获取联系人
                if (_result == null)
                {
                    return(_result);
                }
                _result.Contacts = GetWorkPlanContacts(wid);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取年度计划详情", "GetWorkPlanDetial", ex);
            }
            return(_result);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 新建广告信息
 /// </summary>
 /// <param name="Data"></param>
 /// <returns></returns>
 public bool InsterAdvertisement(Advertisement Data)
 {
     try
     {
         string sql = @" INSERT into de2_advertisement(title, targetUrl, imageUrl, imageBase64, `index`, isVail,count,lastModifyTime,regTime) VALUES
                               (@title, @targetUrl, @imageUrl, @imageBase64,@`index`, @isVail,@count,@lastModifyTime,@regTime)";
         Data.imageBase64 = GetImageBase64(Data.imageUrl);
         MySqlClient _MySqlClient = new MySqlClient();
         _MySqlClient.ExecuteNonQuery(sql, new MySqlParameter("@title", Data.title),
                                      new MySqlParameter("@targetUrl", Data.targetUrl),
                                      new MySqlParameter("@imageUrl", Data.imageUrl),
                                      new MySqlParameter("@imageBase64", Data.imageBase64),
                                      new MySqlParameter("@`index`", Convert.ToInt32(Data.index)),
                                      new MySqlParameter("@isVail", true),
                                      new MySqlParameter("@count", Convert.ToInt32(0)),
                                      new MySqlParameter("@lastModifyTime", DateTime.Now),
                                      new MySqlParameter("@regTime", DateTime.Now)
                                      );
         return(true);
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "新建广告信息", "InsterAdvertisement", ex);
         return(false);
     }
 }
Exemplo n.º 6
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            LogFactory.CreateLog().LogError(ex);
            MessageBox.Show(string.Format("{0}\n\nInformación:\n{1}", "Ha ocurrido un error en la ejecución de la aplicación", ex.Message), "AJMigratorApp", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 验证用户是否存在
        /// </summary>
        /// <param name="LoginName"></param>
        /// <param name="UserKey">新建时为空</param>
        /// <returns></returns>
        public bool LoginNameIsRepeat(string LoginName, Guid UserKey)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.AppendLine("select count(id) from de2_user where loginName=@loginName ");
                if (UserKey != Guid.Empty)
                {
                    sql.AppendLine(" && userKey=@userKey");
                }
                MySqlClient _MySqlClient = new MySqlClient();
                int         UserCount    = 0;
                if (UserKey != Guid.Empty)
                {
                    UserCount = Convert.ToInt32(_MySqlClient.ExecuteScalar(sql.ToString(), new MySqlParameter("loginName", LoginName), new MySqlParameter("userKey", UserKey)));
                }
                else
                {
                    UserCount = Convert.ToInt32(_MySqlClient.ExecuteScalar(sql.ToString(), new MySqlParameter("loginName", LoginName)));
                }
                if (UserCount > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "验证用户是否存在", "LoginNameIsRepeat", ex);
                return(true);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取关注作者列表
        /// </summary>
        /// <param name="Start"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public List <Concerns> GetConcernsList(int StartRow, int PageSize)
        {
            List <Concerns> result = new List <Concerns>();

            try
            {
                //获取当前用户
                AccountProvider _AccountProvider = new AccountProvider();
                var             user             = _AccountProvider.GetCurrentUser();
                if (user == null || user.id == 0)
                {
                    return(result);
                }
                string      sql     = "select * from de2_concerns where createID=@userID order by createTime DESC";
                MySqlClient _client = new MySqlClient();
                result = _client.ExecuteQuery <Concerns>(sql.ToString(),
                                                         new MySqlParameter("@userID", user.id));
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取关注作者列表", "GetCollectionList", ex);
            }
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取收藏列表
        /// </summary>
        /// <param name="StartRow">开始行</param>
        /// <param name="PageSize">页面数据大小</param>
        /// <param name="userID">用户ID</param>
        /// <returns></returns>
        public List <Archives> GetCollectionList(int StartRow, int PageSize, int userID)
        {
            List <Archives> Result = new List <Archives>();

            try
            {
                //生成检索语句
                StringBuilder sql = new StringBuilder();
                sql.AppendLine("select ar.* from de2_archives as ar join  de2_collection as co on ar.id=co.aid  where co.createID=@userID");

                sql.AppendLine(" order by sortrank desc");
                sql.AppendLine(" limit @start,@count ");
                MySqlClient _client = new MySqlClient();

                Result = _client.ExecuteQuery <Archives>(sql.ToString(),
                                                         new MySqlParameter("@start", StartRow),
                                                         new MySqlParameter("@count", PageSize),
                                                         new MySqlParameter("@userID", userID));
                Result = FromateLitpic(Result);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取收藏列表", "GetCollectionList", ex);
            }
            return(Result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 转换数据行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="row"></param>
        /// <returns></returns>
        private T DataRowToObject <T>(DataRow row)
        {
            T obj = default(T);

            if (row != null)
            {
                obj = Activator.CreateInstance <T>();

                foreach (DataColumn column in row.Table.Columns)
                {
                    PropertyInfo prop = obj.GetType().GetProperty(column.ColumnName);
                    if (prop == null)
                    {
                        continue;
                    }
                    try
                    {
                        object value = row[column.ColumnName];
                        prop.SetValue(obj, value.ConvertTo(prop.PropertyType), null);
                    }
                    catch (Exception ex)
                    {  //You can log something here
                        LogFactory _LogFactory = new LogFactory(this.GetType());
                        _LogFactory.CreateLog(LogType.Error, "转换数据行", "DataRowToObject", ex);
                    }
                }
            }
            return(obj);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Executes the command
        /// </summary>
        public void Execute()
        {
            if (BeforeExecute != null)
            {
                BeforeExecute(this, new BeforeExecuteEventArgs());
            }

            try
            {
                DoExecute();
            }
            catch (Exception ex)
            {
                LogFactory.CreateLog().LogError(ex.Message, ex);

                if (ExecuteError != null)
                {
                    ExecuteError(this, new ExecuteErrorEventArgs(ex));
                }
            }

            if (AfterExecute != null)
            {
                AfterExecute(this, new AfterExecuteEventArgs());
            }
        }
Exemplo n.º 12
0
        public async Task <bool> ExecuteAsync()
        {
            var result = false;

            if (BeforeExecute != null)
            {
                BeforeExecute(this, new BeforeExecuteEventArgs());
            }

            try
            {
                result = await DoExecuteAsync();
            }
            catch (Exception ex)
            {
                LogFactory.CreateLog().LogError(ex.Message, ex);

                if (ExecuteError != null)
                {
                    ExecuteError(this, new ExecuteErrorEventArgs(ex, true));
                }
            }

            if (AfterExecute != null)
            {
                AfterExecute(this, new AfterExecuteEventArgs());
            }

            return(result);
        }
Exemplo n.º 13
0
        private void DisplayColorFormats()
        {
            cbxColorFormat.Items.Clear();

            try
            {
                var _pixelTypes = _twain.Capabilities.PixelType.Get();

                for (int index = 0; index < _pixelTypes.Count; index++)
                {
                    if (_pixelTypes[index].ToString() == "RGB")
                    {
                        cbxColorFormat.Items.Add("Color");
                    }

                    if (_pixelTypes[index].ToString() == "Gray")
                    {
                        cbxColorFormat.Items.Add("Escala de grises");
                    }

                    if (_pixelTypes[index].ToString() == "BW")
                    {
                        cbxColorFormat.Items.Add("Blanco y negro");
                    }
                }
            }
            catch (TwainException ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ErrorMessages.PixelsNotAviableError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 14
0
        public void ErrorLog()
        {
            LogFactory factory = ErrorLogFactory.GetFactory();
            Log        log     = factory.CreateLog("Błąd!");

            Assert.True(log.type == "ERROR");
        }
Exemplo n.º 15
0
        public void WarnLog()
        {
            LogFactory factory = WarningLogFactory.GetFactory();
            Log        log     = factory.CreateLog("UWAGA!");

            Assert.True(log.type == "WARN");
        }
Exemplo n.º 16
0
        private void DisplayResolutions()
        {
            cbxResolution.Items.Clear();

            try
            {
                var resolutions = _twain.Capabilities.XResolution.Get();

                if (resolutions.Count > 0)
                {
                    for (int index = 0; index < resolutions.Count; index++)
                    {
                        if (float.Parse(resolutions[index].ToString()) >= 200)
                        {
                            cbxResolution.Items.Add(resolutions[index].ToString());
                        }
                    }
                }

                if (cbxResolution.Items.Count > 0)
                {
                    cbxResolution.SelectedIndex = 0;
                }
            }
            catch (TwainException ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ErrorMessages.ResolutionsNotAviableError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 17
0
        private void NewScanForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.DialogResult == DialogResult.OK)
            {
                this.Cursor = Cursors.WaitCursor;

                try
                {
                    CreateScannedImagesList();
                }
                catch (Exception ex)
                {
                    LogFactory.CreateLog().LogError(ex);
                    MessageBox.Show(ErrorMessages.AsyncTaskError, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
            else
            {
                _closingWindow = true;
            }

            _twain.CloseDSM();
        }
Exemplo n.º 18
0
        /// <summary>
        /// 获取文章详情
        /// </summary>
        /// <returns></returns>
        public ArticleDetial GetArticleDetial(int aid)
        {
            ArticleDetial result = new ArticleDetial();

            try
            {
                result.BaseInfro = GetArchives(aid);
                result.Body      = GetAddonarticle(aid);
                //修改点击次数
                UpdataClickCount(aid);
                //获取当前登录人
                AccountProvider _AccountProvider = new AccountProvider();
                var             user             = _AccountProvider.GetCurrentUser();
                if (user == null)
                {
                    return(result);
                }
                //验证是否被关注
                result.isFouce = IsFocues(result.BaseInfro.writer, user.id);
                //验证是否被收藏
                result.isCollection = IsCollection(result.BaseInfro.id, user.id);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取文章详情", "GetArticleDetial", ex);
            }
            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="type">0:新建;1:编辑</param>
        /// <returns></returns>
        private RegUserResult CheckUserData(User Data)
        {
            RegUserResult _RegUserResult = new RegUserResult();

            try
            {
                //验证用户名
                _RegUserResult = CheckUserName(Data);
                if (!_RegUserResult.isSuccess)
                {
                    return(_RegUserResult);
                }
                //验证密码
                _RegUserResult = CheckPassword(Data.password);
                if (!_RegUserResult.isSuccess)
                {
                    return(_RegUserResult);
                }
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "验证用户", "CheckUserData", ex);
                _RegUserResult.isSuccess  = false;
                _RegUserResult.errMessage = "用户注册失败";
            }
            _RegUserResult.isSuccess = true;
            return(_RegUserResult);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获取头条新闻
        /// </summary>
        /// <param name="Count"></param>
        /// <returns></returns>
        public List <Archives> GetHeadline(int Count)
        {
            List <Archives> Result = new List <Archives>();

            try
            {
                log.SaveLog("开始获取数据!");
                AccountProvider _AccountProvider = new AccountProvider();
                //获取访问权限
                int VewBrowsePermissions = _AccountProvider.GetBrowsePermissions();
                //生成检索语句
                string sql = string.Format("select * from de2_archives where  flag like '%h%' and arcrank!=-1 and( arcrank=0 or arcrank={0} )order by sortrank desc limit @limit", VewBrowsePermissions);

                MySqlClient _client = new MySqlClient();
                log.SaveLog("开始执行SQL!");
                Result = _client.ExecuteQuery <Archives>(sql, new MySqlParameter("@limit", Count));
                log.SaveLog("完成SQL!");
                Result = FromateLitpic(Result);
            }
            catch (Exception ex)
            {
                log.SaveLog("执行错误!" + ex.Message);
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取头条新闻", "GetHeadline", ex);
            }
            return(Result);
        }
Exemplo n.º 21
0
 /// <summary>
 /// 修改用户信息
 /// </summary>
 /// <param name="Data"></param>
 /// <returns></returns>
 public bool UpdateMember(Member Data)
 {
     try
     {
         string      sql          = @"update de2_user set address=@address,email=@email,sex=@sex,addressProvinceID=@addressProvinceID,addressProvince=@addressProvince,addressCityID=@addressCityID,addressCity=@addressCity ,age=@age,mobileNO=@mobileNO,pid=@professionID,oid=@occupationID where id=@id;
           update de2_user_member set areaID=@areaID,branchID=@branchID where userid=@id";
         MySqlClient _MySqlClient = new MySqlClient();
         _MySqlClient.ExecuteNonQuery(sql,
                                      new MySqlParameter("branchID", Data.branchID),
                                      new MySqlParameter("areaID", Data.areaID),
                                      new MySqlParameter("address", Data.address),
                                      new MySqlParameter("email", Data.email),
                                      new MySqlParameter("sex", Data.sex),
                                      new MySqlParameter("addressProvinceID", Data.addressProvinceID),
                                      new MySqlParameter("addressProvince", Data.addressProvince),
                                      new MySqlParameter("addressCityID", Data.addressCityID),
                                      new MySqlParameter("addressCity", Data.addressCity),
                                      new MySqlParameter("age", Data.age),
                                      new MySqlParameter("mobileNO", Data.mobileNO),
                                      new MySqlParameter("occupationID", Data.occupationID),
                                      new MySqlParameter("professionID", Data.professionID),
                                      new MySqlParameter("id", Data.id)
                                      );
         return(true);
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "修改用户信息", "UpdateMember", ex);
         return(false);
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// 缓存jsonData
 /// </summary>
 /// <returns></returns>
 public bool StartJsonDataCatch()
 {
     try
     {
         DataCacheProvider _DataCacheProvider = new DataCacheProvider();
         //清空缓存
         _DataCacheProvider.ClearCache();
         //
         SetCache <MenuModel>(_DataCacheProvider, Constant.MainMenuJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.ManagementRegulationsJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.NewsMenuJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.OrganizationalTypeJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.AssociationMenuJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.AboutJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.PublicationTypeJsonFile);
         SetCache <MenuModel>(_DataCacheProvider, Constant.AcademicResourceJsonFile);
         SetCache <Content>(_DataCacheProvider, Constant.ContentDataJsonFile);
         //缓存角色数据
         CacheRole(_DataCacheProvider);
         return(true);
     }
     catch (Exception ex)
     {
         LogFactory _LogFactory = new LogFactory(this.GetType());
         _LogFactory.CreateLog(LogType.Error, "缓存jsonData", "StartJsonDataCatch", ex);
         return(false);
     }
 }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            var queue        = new ConcurrentQueue <PresenceContainer>();
            var dataEvent    = new AutoResetEvent(false);
            var config       = new XmlConfiguration();
            var configValues = config.Deserialize();

            var alarm  = AlarmFactory.CreateAlarm(configValues.Alarm);
            var filter = FilterFactory.CreateFilter(configValues.Filter);
            var log    = LogFactory.CreateLog(configValues.Log);

            var producer   = new Producer(queue);
            var consumer   = new Consumer(queue, dataEvent);
            var controller = new CtrlHospitalBed(dataEvent, consumer, alarm, filter, log);

            var consumerThread   = new Thread(consumer.Run);
            var producerThread   = new Thread(producer.Run);
            var controllerThread = new Thread(controller.RunSystem);
            var checkThread      = new Thread(controller.CheckKeyChar);

            consumerThread.Start();
            producerThread.Start();
            controllerThread.Start();
            checkThread.Start();
        }
Exemplo n.º 24
0
        public static bool AddFieldToTable(FieldInfo fieldInfo, int modelId)
        {
            IList <FieldInfo>     list = new List <FieldInfo>();
            string                xmlFieldByModelId = GetXmlFieldByModelId(modelId);
            Serialize <FieldInfo> serialize         = new Serialize <FieldInfo>();

            if (!string.IsNullOrEmpty(xmlFieldByModelId))
            {
                list = serialize.DeserializeFieldList(xmlFieldByModelId);
            }
            else
            {
                LogInfo info = new LogInfo();
                info.Category   = LogCategory.SystemAction;
                info.Message    = "模型ID 为" + modelId.ToString() + "的模型没有获取到字段";
                info.ScriptName = "ModelManager.cs";
                info.Source     = "GetXmlFieldByModelId(modelId)返回的内容为空";
                info.Timestamp  = DateTime.Now;
                info.Title      = "AddFieldToTable方法出错";
                info.UserName   = "******";
                LogFactory.CreateLog().Add(info);
            }
            list.Add(fieldInfo);
            xmlFieldByModelId = serialize.SerializeFieldList(list);
            bool flag = false;

            flag = UpdateField(modelId, xmlFieldByModelId);
            if (flag && (fieldInfo.FieldType != FieldType.Property))
            {
                flag = AddTableField(fieldInfo, modelId);
            }
            return(flag);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 获取广告列表
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public BaseResopne <List <Advertisement> > GetAdvertisementes(GetAdvertisementesParam Param)
        {
            BaseResopne <List <Advertisement> > result = new BaseResopne <List <Advertisement> >();

            try
            {
                StringBuilder sql      = new StringBuilder();
                StringBuilder countSql = new StringBuilder();
                sql.AppendLine("select * from de2_advertisement");
                countSql.AppendLine("select count(id) from de2_advertisement");

                sql.AppendLine("order by `index` desc limit @start,@count");
                // string sql = string.Format("select * from de2_advertisement  order by index desc limit @limit");
                MySqlClient _client = new MySqlClient();

                result.Total = Convert.ToInt32(_client.ExecuteScalar(countSql.ToString()));
                result.Data  = _client.ExecuteQuery <Advertisement>(sql.ToString(), new MySqlParameter("@start", Param.StartRow), new MySqlParameter("@count", Param.PageSize));
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取广告列表", "GetAdvertisementList", ex);
                result.IsSuccess = false;
                result.Error     = ex.Message;
            }
            return(result);
        }
Exemplo n.º 26
0
        private void DisplayColorFormats()
        {
            rbtnRGB.Enabled  = rbtnRGB.Checked = false;
            rbtnGray.Enabled = rbtnGray.Checked = false;
            rbtnBW.Enabled   = rbtnBW.Checked = false;

            try
            {
                var _pixelTypes = _twain.Capabilities.PixelType.Get();

                for (int index = 0; index < _pixelTypes.Count; index++)
                {
                    if (_pixelTypes[index].ToString() == "RGB")
                    {
                        rbtnRGB.Enabled = true;
                        rbtnRGB.Checked = true;
                    }

                    if (_pixelTypes[index].ToString() == "Gray")
                    {
                        rbtnGray.Enabled = true;
                    }

                    if (_pixelTypes[index].ToString() == "BW")
                    {
                        rbtnBW.Enabled = true;
                    }
                }
            }
            catch (TwainException ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ErrorMessages.PixelsNotAviableError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 保存联系人
        /// </summary>
        /// <param name="Data">数据</param>
        /// <returns></returns>
        public bool SaveWorkPlanContacts(WorkPlan Data)
        {
            try
            {
                if (Data.Contacts == null || Data.Contacts.Count == 0)
                {
                    return(true);
                }
                var result = false;
                foreach (var item in Data.Contacts)
                {
                    switch (item.statue.ToLower())
                    {
                    case "add":
                        result = AddWorkPlanContacts(item, Data.id);
                        break;

                    case "edit":
                        result = UpdateWorkPlanContacts(item);
                        break;

                    case "del":
                        result = DelWorkPlanContacts(item.id);
                        break;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "保存联系人", "SaveWorkPlanContacts", ex);
                return(false);
            }
        }
Exemplo n.º 28
0
        private void EndXfer(object sender, Twain32.EndXferEventArgs e)
        {
            if (_closingWindow)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            try
            {
                if (e.Image != null)
                {
                    _images.Add(e.Image);
                    _imageIndex = _images.Count - 1;
                    SetImage(e.Image);
                }
            }
            catch (Exception ex)
            {
                LogFactory.CreateLog().LogError(ex);
                MessageBox.Show(ErrorMessages.AsyncTaskError, "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 29
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            LogFactory.CreateLog().LogError(ex);
            MessageBox.Show(string.Format("{0}\n\nInformación:\n{1}", ErrorMessages.AsyncTaskError, ex.Message), "Doku4Invoices", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 删除目录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BaseResopne <string> DelResourceMenu(int id)
        {
            BaseResopne <string> result = new BaseResopne <string>();

            try
            {
                //删除文件
                if (DelResourcesFileByParent(id))
                {
                    result.IsSuccess = false;
                    result.Error     = "资源文件删除失败";
                    return(result);
                }
                //删除目录
                string sql = "delete from de2_aresource_menu where id=@id";
                //
                MySqlClient _Client = new MySqlClient();
                _Client.ExecuteNonQuery(sql, new MySqlParameter("@id", id));
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "删除目录", "DelResourceMenu", ex);
                result.IsSuccess = false;
            }
            return(result);
        }