Example #1
0
        private void EmplUpdateIntegration(string _firstname, string _secondname, string _middlename, Guid _company, string _managerUserId)
        {
            IEmplService _EmplService = DependencyResolver.Current.GetService <IEmplService>();
            Guid?        manageId     = null;

            if (_managerUserId != String.Empty)
            {
                if (_EmplService.Contains(x => x.CompanyTableId == _company &&
                                          x.ApplicationUserId == _managerUserId))
                {
                    manageId = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company &&
                                                           x.ApplicationUserId == _managerUserId).Id;

                    if (_EmplService.Contains(x => x.CompanyTableId == _company &&
                                              x.FirstName == _firstname &&
                                              x.MiddleName == _middlename &&
                                              x.SecondName == _secondname))
                    {
                        EmplTable empl = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company &&
                                                                     x.FirstName == _firstname &&
                                                                     x.MiddleName == _middlename &&
                                                                     x.SecondName == _secondname);

                        empl.ManageId = manageId;
                        _EmplService.SaveDomain(empl, "Admin");
                    }
                }
            }
        }
Example #2
0
        private void EmplIntegration(string _firstname, string _secondname, string _middlename, string _workphone, string _mobilephone, string _userId, Guid _departmentId, Guid _titleId, Guid _company, string _managerUserId)
        {
            IEmplService         _EmplService         = DependencyResolver.Current.GetService <IEmplService>();
            IWorkScheduleService _WorkScheduleService = DependencyResolver.Current.GetService <IWorkScheduleService>();
            Guid?manageId = null;

            if (_managerUserId != String.Empty)
            {
                if (_EmplService.Contains(x => x.CompanyTableId == _company &&
                                          x.ApplicationUserId == _managerUserId))
                {
                    manageId = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company &&
                                                           x.ApplicationUserId == _managerUserId).Id;
                }
            }

            if (!_EmplService.Contains(x => x.CompanyTableId == _company &&
                                       x.FirstName == _firstname &&
                                       x.MiddleName == _middlename &&
                                       x.SecondName == _secondname))
            {
                _EmplService.SaveDomain(new EmplTable()
                {
                    isIntegratedLDAP    = true,
                    FirstName           = _firstname,
                    SecondName          = _secondname,
                    MiddleName          = _middlename,
                    ApplicationUserId   = _userId,
                    DepartmentTableId   = _departmentId,
                    TitleTableId        = _titleId,
                    CompanyTableId      = _company,
                    WorkScheduleTableId = _WorkScheduleService.FirstOrDefault(x => x.Id != null).Id,
                    ManageId            = manageId
                }, "Admin");
            }
            else
            {
                EmplTable empl = _EmplService.FirstOrDefault(x => x.CompanyTableId == _company &&
                                                             x.FirstName == _firstname &&
                                                             x.MiddleName == _middlename &&
                                                             x.SecondName == _secondname);

                empl.FirstName         = _firstname;
                empl.SecondName        = _secondname;
                empl.MiddleName        = _middlename;
                empl.DepartmentTableId = _departmentId;
                empl.TitleTableId      = _titleId;
                empl.isIntegratedLDAP  = true;
                empl.ManageId          = manageId;
                _EmplService.SaveDomain(empl, "Admin");
            }
        }
Example #3
0
        public WFUserFunctionResult WFMatchingUpManager(Guid documentId, string currentUserName, int level = 1, string profileName = "")
        {
            bool skip          = false;
            var  documentTable = _DocumentService.Find(documentId);
            List <WFTrackerUsersTable> userList = new List <WFTrackerUsersTable>();
            EmplTable currentEmplUser           = _EmplService.FirstOrDefault(x => x.ApplicationUserId == documentTable.ApplicationUserCreatedId);
            EmplTable manager = WFMatchingUpManagerFinder(currentEmplUser, level, currentUserName, profileName);

            if (manager != null)
            {
                userList.Add(new WFTrackerUsersTable {
                    UserId = manager.ApplicationUserId
                });
            }

            if (!String.IsNullOrEmpty(profileName) && !String.IsNullOrWhiteSpace(profileName))
            {
                if (userList.Count == 0)
                {
                    skip = true;
                }
                else
                {
                    skip = checkSkipStep(userList, documentTable.ApplicationUserCreatedId);
                }
            }

            return(new WFUserFunctionResult {
                Users = userList, Skip = skip
            });
        }
Example #4
0
        public ActionResult ShowDocument(Guid id, bool isAfterView = false)
        {
            var previousModelState = TempData["ModelState"] as ModelStateDictionary;

            if (previousModelState != null)
            {
                foreach (KeyValuePair <string, ModelState> kvp in previousModelState)
                {
                    if (!ModelState.ContainsKey(kvp.Key))
                    {
                        ModelState.Add(kvp.Key, kvp.Value);
                    }
                }
            }

            DocumentTable docuTable = _DocumentService.Find(id);
            ProcessView   process   = _ProcessService.FindView(docuTable.ProcessTableId);

            if (docuTable == null || process == null || docuTable.isShow(isAfterView) == false)
            {
                return(RedirectToAction("PageNotFound", "Error"));
            }

            _ReviewDocLogService.SaveDomain(new ReviewDocLogTable {
                DocumentTableId = id
            });

            EmplTable       emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == docuTable.ApplicationUserCreatedId);
            ApplicationUser userTable = _AccountService.Find(docuTable.ApplicationUserCreatedId);

            if (emplTable == null || userTable == null)
            {
                return(HttpNotFound());
            }

            object viewModel = InitialViewShowDocument(id, process, docuTable, userTable, emplTable);

            return(View(viewModel));
        }
Example #5
0
        private void CreateMessange(EmailTemplateType type, DocumentTable docuTable, ApplicationUser userTable, string templateName, string documentUri, string bodyText, string subject, string[] parameters)
        {
            var emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == userTable.Id);

            if (emplTable == null)
            {
                return;
            }

            string processName = String.Empty;

            if (docuTable != null)
            {
                processName = docuTable.ProcessTable.ProcessName;
            }

            EmailParameterView emailParameter = FirstOrDefaultView(x => x.SmtpServer != String.Empty);

            new Task(() =>
            {
                string absFile   = HostingEnvironment.ApplicationPhysicalPath + templateName;
                string razorText = System.IO.File.ReadAllText(absFile);

                string currentLang = Thread.CurrentThread.CurrentCulture.Name;
                CultureInfo ci     = CultureInfo.GetCultureInfo(userTable.Lang);
                Thread.CurrentThread.CurrentCulture   = ci;
                Thread.CurrentThread.CurrentUICulture = ci;
                string body = String.Empty;

                switch (type)
                {
                case EmailTemplateType.Default:
                    body = Razor.Parse(razorText, new { DocumentNum = String.Format("{0} - {1}", docuTable.DocumentNum, processName), DocumentUri = documentUri, EmplName = emplTable.FullName, BodyText = bodyText });
                    break;

                case EmailTemplateType.Comment:
                    body = Razor.Parse(razorText, new { DocumentNum = String.Format("{0} - {1}", docuTable.DocumentNum, processName), DocumentUri = documentUri, EmplName = emplTable.FullName, BodyText = bodyText, LastComment = parameters[0] });
                    break;

                case EmailTemplateType.Delegation:
                    body = Razor.Parse(razorText, new { DocumentUri = documentUri, EmplNameTo = parameters[0], EmplNameFrom = parameters[1], BodyText = bodyText });
                    break;
                }
                SendEmail(emailParameter, new string[] { userTable.Email }, new string[] { }, subject, body);

                ci = CultureInfo.GetCultureInfo(currentLang);
                Thread.CurrentThread.CurrentCulture   = ci;
                Thread.CurrentThread.CurrentUICulture = ci;
            }).Start();
        }
Example #6
0
        public ActionResult Index()
        {
            ApplicationUser userTable = _AccountService.FirstOrDefault(x => x.UserName == User.Identity.Name);

            if (userTable == null)
            {
                ModelState.AddModelError(string.Empty, String.Format(ValidationRes.ValidationResource.ErrorUserNotFound, User.Identity.Name));
            }

            EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == userTable.Id);

            if (emplTable == null)
            {
                ModelState.AddModelError(string.Empty, String.Format(ValidationRes.ValidationResource.ErrorEmplNotFound, User.Identity.Name));
            }

            return(View(_GroupProcessService.GetPartialView(x => x.GroupProcessParentId == null)));
        }
Example #7
0
        public Guid SaveDocument(dynamic viewTable, string tableName, Guid processId, Guid fileId, string currentUserName = "")
        {
            string localUserName = getCurrentUserName(currentUserName);

            var docuTable = new DocumentTable();

            docuTable.ProcessTableId = processId;
            docuTable.CreatedDate    = DateTime.UtcNow;
            docuTable.ModifiedDate   = docuTable.CreatedDate;
            docuTable.DocumentState  = DocumentState.Created;
            docuTable.FileId         = fileId;

            ApplicationUser user = _AccountService.FirstOrDefault(x => x.UserName == localUserName);

            docuTable.CompanyTableId            = user.CompanyTableId;
            docuTable.ApplicationUserCreatedId  = user.Id;
            docuTable.ApplicationUserModifiedId = user.Id;

            EmplTable emplTable = _EmplService.FirstOrDefault(x => x.ApplicationUserId == user.Id);

            docuTable.EmplTableId = emplTable.Id;

            Guid numberSeqId = _ProcessService.Find(processId).GroupProcessTable.NumberSeriesTableId ?? Guid.Empty;

            docuTable.DocumentNum = _NumberSeqService.GetDocumentNum(numberSeqId);
            _uow.GetRepository <DocumentTable>().Add(docuTable);
            _uow.Save();

            var domainTable = RouteCustomModelDomain(tableName);

            Mapper.Map(viewTable, domainTable);
            domainTable.DocumentTableId = docuTable.Id;
            domainTable.CreatedDate     = DateTime.UtcNow;
            domainTable.ModifiedDate    = domainTable.CreatedDate;
            RouteCustomRepository(tableName).Add(domainTable);
            _uow.Save();

            docuTable.RefDocumentId = domainTable.Id;
            _uow.GetRepository <DocumentTable>().Update(docuTable);
            _uow.Save();

            return(docuTable.Id);
        }
        public IEnumerable <WFTrackerListView> GetPartialView(Expression <Func <WFTrackerTable, bool> > predicate)
        {
            IEnumerable <WFTrackerTable> trackerDomainItems = GetPartial(predicate).OrderBy(x => x.LineNum);
            List <WFTrackerListView>     trackerViewItems   = new List <WFTrackerListView>();
            int    rowNum = 0;
            int    tmpNum;
            string workers;
            string prevActivityID = String.Empty;

            foreach (var item in trackerDomainItems)
            {
                workers = String.Empty;

                foreach (var userItem in item.Users)
                {
                    var empl = _EmplService.FirstOrDefault(x => x.ApplicationUserId == userItem.UserId);

                    if (workers != String.Empty)
                    {
                        workers += ", ";
                    }

                    workers += string.Format("({0}) {1} - {2}", empl.CompanyTable.AliasCompanyName, empl.FullName, empl.TitleTable.TitleName);

                    var delegationItems = _DelegationService.GetPartial(x => x.EmplTableFromId == empl.Id &&
                                                                        x.DateFrom <= DateTime.UtcNow && x.DateTo >= DateTime.UtcNow &&
                                                                        x.isArchive == false && x.CompanyTableId == empl.CompanyTable.Id);

                    bool addUser;
                    foreach (var delegationItem in delegationItems)
                    {
                        addUser = false;
                        if (delegationItem.GroupProcessTableId != null || delegationItem.ProcessTableId != null)
                        {
                            if (delegationItem.ProcessTableId == item.DocumentTable.ProcessTableId)
                            {
                                addUser = true;
                            }
                            else if (delegationItem.GroupProcessTableId == item.DocumentTable.ProcessTable.GroupProcessTableId)
                            {
                                addUser = true;
                            }
                        }
                        else
                        {
                            addUser = true;
                        }

                        if (addUser == true)
                        {
                            workers += string.Format(" ==> ({0}) {1} - {2}", delegationItem.EmplTableTo.CompanyTable.AliasCompanyName, delegationItem.EmplTableTo.FullName, delegationItem.EmplTableTo.TitleTable.TitleName);
                        }
                    }
                }

                if (item.ParallelID != String.Empty)
                {
                    if (prevActivityID != item.ParallelID)
                    {
                        rowNum = rowNum + 1;
                    }
                    tmpNum = rowNum;

                    if (prevActivityID != item.ParallelID)
                    {
                        prevActivityID = item.ParallelID;
                    }
                }
                else
                {
                    rowNum         = rowNum + 1;
                    tmpNum         = rowNum;
                    prevActivityID = String.Empty;
                }

                if (item.SignDate != null)
                {
                    var signEmpl = _EmplService.FirstOrDefault(x => x.ApplicationUserId == item.SignUserId);
                    trackerViewItems.Add(new WFTrackerListView {
                        ActivityName = item.ActivityName, RowNum = tmpNum, Executors = signEmpl.FullName, SignDate = item.SignDate, TrackerType = item.TrackerType, ActivityID = item.ActivityID, SLAOffset = item.SLAOffset, CreatedDate = item.CreatedDate, PerformToDate = item.PerformToDate()
                    });
                }
                else
                {
                    trackerViewItems.Add(new WFTrackerListView {
                        ActivityName = item.ActivityName, RowNum = tmpNum, Executors = workers, TrackerType = item.TrackerType, ManualExecutor = item.ManualExecutor, ActivityID = item.ActivityID, SLAOffset = item.SLAOffset, CreatedDate = item.CreatedDate, PerformToDate = item.PerformToDate()
                    });
                }
            }

            return(trackerViewItems);
        }