Example #1
0
        [WebMethod] // 删除指定模板
        public int fun10(int _class, string _LabelId)
        {
            AppInit.Init();
            DataUpdate             dbUpdate = new DataUpdate();
            BarcodePrintRepository rep      = new BarcodePrintRepository();

            try
            {
                dbUpdate.BeginTransaction();
                rep.DbUpdate = dbUpdate;
                string labelType = "";
                if (_class == 0)
                {
                    labelType = "Z";
                }
                else
                {
                    labelType = "C";
                }
                rep.DeleteStyle(labelType, _LabelId, "Print Tools Update");
                dbUpdate.Commit();
                return(1);
            }
            catch (Exception)
            {
                dbUpdate.Rollback();
                return(0);
            }
            finally
            {
                dbUpdate.Close();
            }
        }
Example #2
0
 public static void ExcuteAutoUpdateByThread()
 {
     if (!TaskExcuting)
     {
         TaskExcuting = true;
         //AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Debug, "AutoTask", string.Format(AppMember.AppText["AutoDepreciationProcess"]));
         AssetsDepreciationRepository rep = new AssetsDepreciationRepository();
         DataUpdate dbUpdate = new DataUpdate();
         try
         {
             dbUpdate.BeginTransaction();
             rep.DbUpdate = dbUpdate;
             rep.UpdateAuto(AppMember.AppText["MonthAutoUpdate"]);
             dbUpdate.Commit();
         }
         catch (Exception ex)
         {
             dbUpdate.Rollback();
             AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AutoTask", ex.Message);
             throw ex;
         }
         finally
         {
             dbUpdate.Close();
             TaskExcuting = false;
         }
     }
 }
 public ActionResult BatchDelete(string pageId, string formMode, string viewTitle, string gridString, string isCascadeDelete)
 {
     try
     {
         UserInfo         sysUser  = CacheInit.GetUserInfo(HttpContext);
         AssetsRepository arep     = new AssetsRepository();
         DataUpdate       dbUpdate = new DataUpdate();
         try
         {
             dbUpdate.BeginTransaction();
             arep.DbUpdate = dbUpdate;
             arep.BatchDelete(sysUser, gridString, viewTitle, isCascadeDelete);
             dbUpdate.Commit();
             return(Content("1"));
         }
         catch (Exception)
         {
             dbUpdate.Rollback();
             return(Content(AppMember.AppText["DeleteExistRefrence"]));
         }
         finally
         {
             dbUpdate.Close();
         }
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsManageController.BatchDelete post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
Example #4
0
 public ActionResult ReplaceFavorit(string tableName, string pkValue)
 {
     try
     {
         UserInfo   sysUser  = CacheInit.GetUserInfo(HttpContext);
         DataUpdate dbUpdate = new DataUpdate();
         try
         {
             dbUpdate.BeginTransaction();
             CacheRepository drep = new CacheRepository();
             drep.DbUpdate = dbUpdate;
             drep.ReplaceFavorit(pkValue, sysUser.UserId, tableName);
             dbUpdate.Commit();
         }
         catch (Exception ex)
         {
             dbUpdate.Rollback();
             throw new Exception(ex.Message);
         }
         finally
         {
             dbUpdate.Close();
         }
         return(Content("0", "text/html"));
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "MasterController.ReplaceFavorit", ControllerName + "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content(ControllerName + "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
Example #5
0
        protected int Update(IMaintain rep, EntryViewModel model, string viewTitle)
        {
            UserInfo   sysUser  = CacheInit.GetUserInfo(HttpContext);
            DataUpdate dbUpdate = new DataUpdate();

            try
            {
                dbUpdate.BeginTransaction();
                rep.DbUpdate = dbUpdate;
                rep.Update(model, sysUser, viewTitle);
                dbUpdate.Commit();
                return(1);
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback();
                model.Message  = ex.Message;
                model.HasError = "true";
                return(0);
            }
            finally
            {
                dbUpdate.Close();
            }
        }
Example #6
0
 public ActionResult Entry(EntryModel model)
 {
     if (ModelState.IsValid)
     {
         string      gridHidStr  = model.GridId + model.PageId + AppMember.HideString;
         List <Test> gridData    = JsonHelper.JSONStringToList <Test>(Request.Form[gridHidStr]);
         string      delPkHidStr = model.GridId + model.PageId + AppMember.DeletePK;
         string      delPks      = Request.Form[delPkHidStr];
         UserInfo    sysUser     = CacheInit.GetUserInfo(HttpContext);
         DataUpdate  dbUpdate    = new DataUpdate();
         dbUpdate.BeginTransaction();
         TestRepository rep = new TestRepository(dbUpdate);
         Dictionary <string, object> objs = new Dictionary <string, object>();
         objs.Add("gridData", gridData);
         objs.Add("deletePks", delPks);
         try
         {
             rep.Save(objs, sysUser, model.ViewTitle);
             dbUpdate.Commit();
         }
         catch (Exception ex)
         {
             dbUpdate.Rollback();
             throw new Exception(ex.Message);
         }
         model.HasError = "false";
     }
     else
     {
         model.HasError = "true";
     }
     model.GridLayout = GridLayout();
     return(View(model));
 }
Example #7
0
        public int AddData(Dictionary <string, object> objs, UserInfo sysUser, string viewTitle, string tableName, string pkField, string pkValue, bool isReturn)
        {
            string    sql = @"select * from AppApprove where 1<>1 ";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql).Tables[0];

            dt.TableName = "AppApprove";
            DataRow dr = dt.NewRow();

            cmd = dbUpdate.BeginTransaction();
            try
            {
                foreach (KeyValuePair <string, object> kv in objs)
                {
                    dr[kv.Key] = kv.Value;
                }
                dr["approveId"] = IdGenerator.GetMaxId(dt.TableName);
                Create5Field(dr, sysUser.UserId, viewTitle);
                dt.Rows.Add(dr);
                dbUpdate.Update(dt, cmd);
                OverrideRefTable(tableName, pkField, pkValue, sysUser, viewTitle, isReturn);
                dbUpdate.Commit(cmd);
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback(cmd);
                throw new Exception(ex.Message);
            }
            return(1);
        }
        protected int Update(IApproveEntry rep, ApproveEntryViewModel model, string pkValue, string approveReturn)
        {
            UserInfo   sysUser  = CacheInit.GetUserInfo(HttpContext);
            DataUpdate dbUpdate = new DataUpdate();

            try
            {
                dbUpdate.BeginTransaction();
                rep.DbUpdate = dbUpdate;
                if (model.FormMode != "approve")
                {
                    //再申请的,将状态由再申请初期变为再申请
                    if (model.FormMode == "reapply")
                    {
                        ApproveRepository repApprove = new ApproveRepository();
                        repApprove.DbUpdate = rep.DbUpdate;
                        repApprove.EditData(sysUser, model.ViewTitle, model.ApproveTableName, model.ApprovePkField, model.ApprovePkValue, "A", model.ApproveMind, model.ApproveNode);
                    }
                    if (CheckModelIsValid(model))
                    {
                        rep.Update(model, sysUser, model.FormMode, pkValue, model.ViewTitle);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    //ModelState.Clear();
                    if (ApproveAndUpdate(rep, model, pkValue, approveReturn, sysUser) == 0)
                    {
                        return(0);
                    }
                    int val = DealApprove(rep, model, approveReturn, "");
                    if (val == 0)
                    {
                        return(0);
                    }
                }
                dbUpdate.Commit();
                return(1);
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback();
                model.Message  = ex.Message;
                model.HasError = "true";
                AppLog.WriteLog(sysUser.UserName, LogType.Error, "UpdateError", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(0);
            }
            finally
            {
                dbUpdate.Close();
            }
        }
Example #9
0
        //protected void Update(IEntry rep, EntryViewModel model, string mode, string pkValue, string viewTitle)
        //{
        //    UserInfo sysUser = CacheInit.GetUserInfo(HttpContext);
        //    DataUpdate dbUpdate = new DataUpdate(); dbUpdate = new DataUpdate();
        //    try
        //    {
        //        dbUpdate.BeginTransaction();
        //        rep.DbUpdate = dbUpdate;
        //        rep.Update(model, sysUser, mode, pkValue, viewTitle);
        //        dbUpdate.Commit();
        //        CacheInit.RefreshCache(HttpContext, EntryRepository, ControllerName + "DropList", DateTime.Now.AddMinutes(CacheExpiryMinute), CachePriority, CacheCreateType.Immediately);
        //    }
        //    catch (Exception ex)
        //    {
        //        dbUpdate.Rollback();
        //        model.Message = ex.Message;
        //        model.HasError = "true";
        //    }
        //    finally
        //    {
        //        dbUpdate.Close();
        //    }
        //}

        protected virtual int Update(IEntry rep, EntryViewModel model, string pkValue)
        {
            UserInfo   sysUser  = CacheInit.GetUserInfo(HttpContext);
            DataUpdate dbUpdate = new DataUpdate();

            try
            {
                if (CheckModelIsValid(model))
                {
                    if (CheckSelfBeforeSave(model))
                    {
                        dbUpdate.BeginTransaction();
                        rep.DbUpdate = dbUpdate;
                        rep.Update(model, sysUser, model.FormMode, pkValue, model.ViewTitle);
                        dbUpdate.Commit();
                        if (!NotNeedCache)
                        {
                            CacheInit.RefreshCache(HttpContext, EntryRepository, ControllerName + "DropList", DateTime.Now.AddMinutes(CacheExpiryMinute), CachePriority, CacheCreateType.Immediately);
                        }
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback();
                model.Message  = ex.Message;
                model.HasError = "true";
                AppLog.WriteLog(sysUser.UserName, LogType.Error, "UpdateError", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(0);
            }
            finally
            {
                dbUpdate.Close();
            }
        }
 public ActionResult Entry(EntryModel model)
 {
     try
     {
         DataImportRepository rep     = new DataImportRepository();
         UserInfo             sysUser = CacheInit.GetUserInfo(HttpContext);
         string     path      = Server.MapPath("~/Content/uploads/excel/");
         string     fileNames = Request.Form["listExcelFileString"].ToString();
         DataUpdate dbUpdate  = new DataUpdate();
         try
         {
             dbUpdate.BeginTransaction();
             rep.DbUpdate = dbUpdate;
             rep.Import(path, fileNames, sysUser, model.ViewTitle);
             dbUpdate.Commit();
             model.HasError = "false";
         }
         catch (Exception ex)
         {
             dbUpdate.Rollback();
             model.Message  = ex.Message;
             model.HasError = "true";
             AppLog.WriteLog(sysUser.UserName, LogType.Error, "UpdateError", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         }
         finally
         {
             dbUpdate.Close();
         }
         model.EntryGridLayout = EntryGridLayout();
         if (model.HasError == "false")
         {
             return(RedirectToAction("Entry", new { pageId = model.PageId, viewTitle = model.ViewTitle }));
         }
         else
         {
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "DataImportController.Entry post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
Example #11
0
        private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            MonthRecordRepository rep      = new MonthRecordRepository();
            DataUpdate            dbUpdate = new DataUpdate();

            try
            {
                dbUpdate.BeginTransaction();
                rep.DbUpdate = dbUpdate;
                rep.UpdateAuto(AppMember.AppText["MonthAutoUpdate"]);
                dbUpdate.Commit();
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback();
                throw ex;
            }
            finally
            {
                dbUpdate.Close();
            }
        }