示例#1
0
        public static string GetLatinDict(long userId, string token)
        {
            using (var tran = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                string toRet;
                var    repository = new ArDictRepository();

                var predicate = PredicateBuilder.True <ArDict>();
                predicate = predicate.And(p => p.Replacement == token.Trim());

                var dictEntry = repository.LoadSearch(predicate).FirstOrDefault();

                if (dictEntry != null)
                {
                    //Increment occurance
                    dictEntry.Occurance += 1;
                    repository.Edit(dictEntry);

                    BlLog.Log(userId, "Entity", "Edit arabic dictionnary", "ArabicDictModified", new object[] { dictEntry.Token, dictEntry.Replacement, dictEntry.Occurance });

                    toRet = dictEntry.Token;
                }
                else
                {
                    toRet = "";
                }

                tran.Complete();
                return(toRet);
            }
        }
 /// <summary>
 /// 将所有CIM参数写入到ini,部分以mode为section保存,其余是公共参数
 /// </summary>
 public void WriteCimConfig()
 {
     #region params
     WriteCimConfig(CIM_PARAMS.SendQueue.ToString(), StrSendQueue, ETypeMode.ToString());
     WriteCimConfig(CIM_PARAMS.ReadQueue.ToString(), StrReadQueue, ETypeMode.ToString());
     WriteCimConfig(CIM_PARAMS.IP.ToString(), StrIP, ETypeMode.ToString());
     WriteCimConfig(CIM_PARAMS.Port.ToString(), StrPort, ETypeMode.ToString());
     WriteCimConfig(CIM_PARAMS.CycTimes.ToString(), iCycTimes.ToString());
     WriteCimConfig(CIM_PARAMS.UserID.ToString(), StrUserID);
     WriteCimConfig(CIM_PARAMS.Fab.ToString(), StrFab);
     WriteCimConfig(CIM_PARAMS.Area.ToString(), StrArea);
     WriteCimConfig(CIM_PARAMS.Line.ToString(), StrLine);
     WriteCimConfig(CIM_PARAMS.EqpId.ToString(), EqpId);
     WriteCimConfig(CIM_PARAMS.Operation.ToString(), StrOperation);
     WriteCimConfig(CIM_PARAMS.Wo_id.ToString(), Wo_id);
     WriteCimConfig(CIM_PARAMS.ModelNo.ToString(), StrModelNo);
     WriteCimConfig(CIM_PARAMS.RunCard.ToString(), StrLot);
     WriteCimConfig(CIM_PARAMS.COM.ToString(), StrCom);
     WriteCimConfig(CIM_PARAMS.CodeDelay.ToString(), iCodeDelay.ToString());
     WriteCimConfig(CIM_PARAMS.Baudrate.ToString(), iBaudrate.ToString());
     WriteCimConfig(CIM_PARAMS.CodeType.ToString(), ETypeCode.ToString());
     WriteCimConfig(CIM_PARAMS.ModeType.ToString(), ETypeMode.ToString());
     WriteCimConfig(CIM_PARAMS.BlLog.ToString(), BlLog.ToString());
     #endregion
 }
示例#3
0
        public Description Create(long userId, Description toAdd)
        {
            Description toRet;

            using (var tran = new TransactionScope())
            {
                //Check if previously exists
                var predicate = PredicateBuilder.True <Description>();
                predicate = predicate.And(p => p.LanguageId == toAdd.LanguageId);
                predicate = predicate.And(p => p.Parent == toAdd.Parent);
                predicate = predicate.And(p => p.Code == toAdd.Code);
                var toCheck = LoadSearch(userId, predicate).SingleOrDefault();
                if (toCheck != null)
                {
                    throw new BusinessException("AlreadyExists1", "lblDescription");
                }

                toRet = _repository.Create(toAdd);

                //Force cash refresh for all module entries
                CacheHelper.Clear(Module);

                BlLog.Log(userId, Module, "Create description", "DescriptionCreated", new object[] { toAdd.Parent, toAdd.Code, toAdd.LanguageId });
                tran.Complete();
            }
            return(toRet);
        }
示例#4
0
        public static string GetAntiDict(long userId, string token)
        {
            using (var tran = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                string toRet;
                var    repository = new AntiDictRepository();
                var    dictEntry  = repository.LoadSingle(token);

                if (dictEntry != null)
                {
                    //Increment occurance
                    dictEntry.Occurance += 1;
                    repository.Edit(dictEntry);

                    BlLog.Log(userId, "Entity", "Edit anti dictionnary", "AntiDictModified", new object[] { dictEntry.Token, dictEntry.Replacement, dictEntry.Occurance });

                    toRet = dictEntry.Replacement;
                }
                else
                {
                    //Create empty dictionary entry for later management
                    CreateEmptyEntry(userId, token);
                    toRet = token;
                }
                tran.Complete();
                return(toRet);
            }
        }
示例#5
0
        public static bool LogOut(long userId)
        {
            var user = LoadSingle(userId, true);

            //Add extra log out code
            BlLog.Log(userId, Module, "LogOut", "UserSuccessfulLogout", new object[] { user.UserName });
            return(true);
        }
示例#6
0
        public Document Edit(long userId, Document toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit document", "DocumentModified", new object[] { toEdit.Name, toEdit.Reference });
                tran.Complete();
                return(toRet);
            }
        }
示例#7
0
        public Document Create(long userId, Document toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create document", "DocumentCreated", new object[] { toAdd.Name, toAdd.Reference });
                tran.Complete();
                return(toRet);
            }
        }
示例#8
0
        public Company Edit(long userId, Company toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Delete company", "CompanyModified", new object[] { toEdit.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#9
0
        public bool Delete(long userId, Address toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete address", "AddressDeleted", new object[] { toDelete.Sequence, toDelete.Entity.Pin, BlEntity.FormatFullName(toDelete.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
示例#10
0
        public bool Delete(long userId, Help toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete help", "HelpDeleted", new object[] { toDelete.Page, toDelete.Ctrl });
                tran.Complete();
                return(toRet);
            }
        }
示例#11
0
        public Help Edit(long userId, Help toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit help", "HelpModified", new object[] { toEdit.Page, toEdit.Ctrl });
                tran.Complete();
                return(toRet);
            }
        }
示例#12
0
        public Branch Edit(long userId, Branch toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Delete branch", "BranchModified", new object[] { toEdit.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#13
0
        public Employee Edit(long userId, Employee toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit employee", "EmployeeModified", new object[] { toEdit.Entity.Pin, BlEntity.FormatFullName(toEdit.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
示例#14
0
        public Description Edit(long userId, Description toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit description", "DescriptionModified", new object[] { toEdit.Parent, toEdit.Code, toEdit.LanguageId });
                tran.Complete();
                return(toRet);
            }
        }
示例#15
0
        public bool Delete(long userId, Description toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete description", "DescriptionDeleted", new object[] { toDelete.Parent, toDelete.Code, toDelete.LanguageId });
                tran.Complete();
                return(toRet);
            }
        }
示例#16
0
        public bool Delete(long userId, Entity toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete entity", "EntityDeleted", new object[] { toDelete.Pin });
                tran.Complete();
                return(toRet);
            }
        }
示例#17
0
        public bool Delete(long userId, Branch toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete branch", "BranchDeleted", new object[] { toDelete.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#18
0
        public bool Delete(long userId, User toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete user", "UserDeleted", new object[] { toDelete.UserName });
                tran.Complete();
                return(toRet);
            }
        }
示例#19
0
        public Help Create(long userId, Help toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create help", "HelpCreated", new object[] { toAdd.Page, toAdd.Ctrl });
                tran.Complete();
                return(toRet);
            }
        }
示例#20
0
        public Comment Create(long userId, Comment toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create comment", "CommentCreated", new object[] { toAdd.Text.ManageTextLength(100), toAdd.Reference });
                tran.Complete();
                return(toRet);
            }
        }
示例#21
0
        public User Create(long userId, User toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create user", "UserCreated", new object[] { toAdd.UserName });
                tran.Complete();
                return(toRet);
            }
        }
示例#22
0
        public Role Create(long userId, Role toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create role", "RoleCreated", new object[] { toAdd.Code });
                tran.Complete();
                return(toRet);
            }
        }
示例#23
0
        public bool Delete(long userId, Permission toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete permission", "PermissionDeleted", new object[] { toDelete.Id, toDelete.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#24
0
        public Permission Edit(long userId, Permission toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit permission", "PermissionModified", new object[] { toEdit.Id, toEdit.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#25
0
        public Company Create(long userId, Company toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Delete company", "CompanyCreated", new object[] { toAdd.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#26
0
        public bool Delete(long userId, Menu toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete menu", "MenuDeleted", new object[] { toDelete.DescriptionCode, toDelete.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#27
0
        public Menu Edit(long userId, Menu toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit menu", "MenuModified", new object[] { toEdit.DescriptionCode, toEdit.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#28
0
        public Menu Create(long userId, Menu toAdd)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create menu", "MenuCreated", new object[] { toAdd.DescriptionCode, toAdd.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#29
0
        public Permission Create(long userId, Permission toAdd)
        {
            using (var tran = new TransactionScope())
            {
                PreSave(userId, ref toAdd, Enumerations.ActionMode.Add);
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create permission", "PermissionCreated", new object[] { toAdd.Code, toAdd.Module.Id });
                tran.Complete();
                return(toRet);
            }
        }
示例#30
0
        public UserVm ProfileSave(long userId, UserVm toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var user = LoadSingle(toEdit.User.Id, true);
                if (toEdit.ChangePassword)
                {
                    if (!Cryptography.ComputeToHash(toEdit.OldPassword).SequenceEqual(user.Password))
                    {
                        throw new BusinessException("WrongOldPassword");
                    }
                    if (!Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Cryptography.ComputeToHash(toEdit.ConfirmPassword)))
                    {
                        throw new BusinessException("NewPasswordDoesNotmatchConfirmation");
                    }
                    user.LastPasswordUpdate = BlCommon.GetServerDateTime();
                    if (user.PasswordHistory != "")
                    {
                        var oldPasswordList = CheckEmpty.String(user.PasswordHistory).Split(',');
                        foreach (var pass in oldPasswordList)
                        {
                            if (Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Convert.FromBase64String(pass)))
                            {
                                throw new BusinessException("NewPasswordFrequentlyUsed");
                            }
                        }
                    }
                    user.PasswordHistory += user.PasswordHistory == "" ? "" : ",";
                    user.PasswordHistory += Convert.ToBase64String(user.Password);
                    var historyLength = BlCode.LoadSingle(userId, "_System", "PasswordHistroyLength").Value1;
                    if (user.PasswordHistory.Split(',').Length > Convert.ToInt32(historyLength))
                    {
                        var newPasswordHistroy = user.PasswordHistory.Split(',').ToList();
                        newPasswordHistroy.RemoveAt(0);
                        user.PasswordHistory = string.Join(",", newPasswordHistroy);
                    }
                    user.Password         = Cryptography.ComputeToHash(toEdit.NewPassword);
                    toEdit.ChangePassword = false;
                }
                user.UserName   = toEdit.User.UserName;
                user.LanguageId = Convert.ToInt16(toEdit.User.LanguageId);
                user.PageSize   = Convert.ToInt16(toEdit.User.PageSize);

                Edit(userId, user);

                //Force cash refresh for module entry
                CacheHelper.Clear(Module + "_" + user.Id.ToUiString());

                BlLog.Log(userId, Module, "Profile change", "UserProfileModified", new object[] { user.UserName });
                tran.Complete();
                return(toEdit);
            }
        }