private bool DeleteTemplate(int templateId)
        {
            var res = false;

            try
            {
                if (templateId > 0)
                {
                    SPListItem templateItem = this.CurrentList.GetItemById(templateId);
                    if (templateItem != null)
                    {
                        templateItem[EmployeeRequirementSheetsList.Fields.IsTemplate] = false;
                        templateItem.Update();
                        res = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentFormUserControl: {ex.Message}");
                res = false;
            }

            return(res);
        }
Exemple #2
0
 public List <DepartmentInfo> GetDepartmentsByLcid(string lcid, string locationIds)
 {
     try
     {
         List <DepartmentInfo> departments        = new List <DepartmentInfo>();
         DepartmentDAL         departmentDAL      = new DepartmentDAL(SPContext.Current.Web.Url);
         List <int>            locationCollection = locationIds.SplitStringOfLocations().ConvertAll(e => Convert.ToInt32(e));
         var departmentList = departmentDAL.GetByLocations(locationCollection);
         if (departmentList.Any())
         {
             foreach (var item in departmentList)
             {
                 string departmentName = lcid.Equals("1066") ? item.VietnameseName : item.Name;
                 departments.Add(new DepartmentInfo()
                 {
                     Id = item.ID, DepartmentName = departmentName
                 });
             }
         }
         return(departments);
     }
     catch (Exception ex)
     {
         ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Service - GetDepartmentsByLcid",
                                                  TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                        string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(null);
     }
 }
        protected override bool SaveForm()
        {
            bool res = false;

            try
            {
                if (this.isEditable)
                {
                    // Set data to list item from form controls
                    this.SaveData();

                    res = base.SaveForm();
                }

                res = true;
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                this.ShowClientMessage(ex.Message);
                return(false);
            }

            return(res);
        }
Exemple #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="assembly">assembly containing embedded resource</param>
        /// <param name="resourceName">resource name in assembly</param>
        public EmbeddedResource(Assembly assembly, string resourceName)
        {
            Assembly = Code.ExpectsArgument(assembly, nameof(assembly), TaggingUtilities.ReserveTag(0x238208c0 /* tag_9669a */));
            Name     = Code.ExpectsNotNullOrWhiteSpaceArgument(resourceName, nameof(resourceName), TaggingUtilities.ReserveTag(0x238208c1 /* tag_9669b */));

            ResourceContent = new Lazy <Tuple <ResourceReadStatus, byte[]> >(() =>
            {
                ResourceReadStatus status = ResourceReadStatus.NotFound;
                byte[] content            = null;
                try
                {
                    string resourceContent = Assembly.LoadEmbeddedResourceAsString(Name);
                    if (resourceContent != null)
                    {
                        content = Encoding.UTF8.GetBytes(resourceContent);
                        status  = ResourceReadStatus.Success;
                    }
                }
                catch (Exception ex)
                {
                    ULSLogging.ReportExceptionTag(0x238208c2 /* tag_9669c */, Categories.ConfigurationDataSet, ex,
                                                  "Unable to read resource {resourceName}", resourceName);
                    status = ResourceReadStatus.ReadFailed;
                }

                return(Tuple.Create(status, content));
            }, LazyThreadSafetyMode.PublicationOnly);
        }
Exemple #5
0
        /// <summary>
        /// Retrieves the XML reader settings.
        /// </summary>
        /// <param name="type">The object type to read.</param>
        /// <param name="schema">The schema to use.</param>
        /// <param name="schemaUri">The schema URI to use.</param>
        /// <returns>The relevant XML reader settings.</returns>
        public static XmlReaderSettings GetXmlReaderSettings(this Type type, string schema, string schemaUri)
        {
            if (type == null)
            {
                ULSLogging.LogTraceTag(0x23820889 /* tag_9668j */, Categories.Common, Levels.Error,
                                       "Null type value passed to GetXmlReaderSettings.");
                return(null);
            }

            if (string.IsNullOrEmpty(schema))
            {
                ULSLogging.LogTraceTag(0x2382088a /* tag_9668k */, Categories.Common, Levels.Error,
                                       "Null or empty schema value passed to GetXmlReaderSettings.");
                return(null);
            }

            XmlSchemaSet schemas = new XmlSchemaSet();

            using (XmlReader reader = XmlReader.Create(type.Assembly.GetManifestResourceStream(schema)))
            {
                schemas.Add(schemaUri, reader);
            }

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ValidationType = ValidationType.Schema;
            settings.Schemas        = schemas;
            return(settings);
        }
        public List <Biz.Models.WorkflowHistory> GetWorkflowHistory(WorkflowHistoryDAL workflowHistoryDAL, string listName, int itemID)
        {
            List <Biz.Models.WorkflowHistory> workflowHistoryItems = null;

            try
            {
                string queryString = string.Format(@"<Where>
                                                        <And>
                                                            <Eq>
                                                                <FieldRef Name='{0}' />
                                                                <Value Type='Text'>{1}</Value>
                                                             </Eq>
                                                            <Eq>
                                                                <FieldRef Name='{2}' />
                                                                <Value Type='Number'>{3}</Value>
                                                             </Eq>
                                                        </And>
                                                   </Where>", WorkflowHistoryList.Fields.ListName, listName,
                                                   WorkflowHistoryList.Fields.CommonItemID, itemID);
                workflowHistoryItems = workflowHistoryDAL.GetByQuery(queryString);
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }

            return(workflowHistoryItems);
        }
        /// <summary>
        /// RequestByDepartment_RowDataBound
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void RequestByDepartment_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    var dataItem = e.Row.DataItem as Biz.Models.EmployeeRequirementSheet;
                    if (dataItem != null)
                    {
                        //string title = dataItem.Title != null ? dataItem.Title : string.Empty;
                        //var litTitle = e.Row.FindControl("litTitle") as Literal;
                        //litTitle.Text = title;

                        string requestFrom = string.Empty;
                        if (dataItem.CommonCreator != null)
                        {
                            requestFrom = dataItem.CommonCreator.LookupValue;
                        }
                        var litRequestFrom = e.Row.FindControl("litRequestFrom") as Literal;
                        litRequestFrom.Text = requestFrom;

                        string departmentName = string.Empty;
                        if (dataItem.RecruitmentDepartment != null)
                        {
                            departmentName = GetDepartmentName(dataItem.RecruitmentDepartment.LookupId);
                        }
                        var litDepartment = e.Row.FindControl("litDepartment") as Literal;
                        litDepartment.Text = departmentName;

                        string position    = dataItem.Position != null ? dataItem.Position : string.Empty;
                        var    litPosition = e.Row.FindControl("litPosition") as Literal;
                        litPosition.Text = position;

                        string quantity    = dataItem.Quantity.ToString();
                        var    litQuantity = e.Row.FindControl("litQuantity") as Literal;
                        litQuantity.Text = quantity;

                        #region ADD. 2017.10.9. TFS#1594
                        var litIsValid = e.Row.FindControl("litIsValid") as Label;
                        if (dataItem.IsValidRequest)
                        {
                            litIsValid.CssClass = RequestIsValid_CssClass;
                        }
                        else
                        {
                            litIsValid.CssClass = RequestIsInvalid_CssClass;
                            e.Row.BackColor     = System.Drawing.ColorTranslator.FromHtml(InvalidRequest_ColorRow);
                        }
                        #endregion

                        base.RequestByDepartment_RowDataBound(sender, e);
                    }
                }
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentListUserControl: {ex.Message}");
            }
        }
Exemple #8
0
        /// <summary>
        /// Get list of calendar in passed Category
        /// </summary>
        /// <param name="categories"></param>
        /// <returns></returns>
        /// Call URL: _vti_bin/Services/Calendar/CalendarService.svc/GetByCategories/
        public List <CalendarModel> GetByCategories(string categories)
        {
            try
            {
                List <string> categoryList = new List <string>();
                categoryList = categories.Split(',').ToList();

                List <CalendarModel> calendars = new List <CalendarModel>();
                var calendarList = _calendarDal.GetByCategories(categoryList);
                foreach (var item in calendarList)
                {
                    calendars.Add(new CalendarModel
                    {
                        ID          = item.ID,
                        Description = item.Description,
                        EndDate     = item.EndDate,
                        StartDate   = item.StartDate,
                        Location    = item.Location,
                        Category    = item.Category,
                        Title       = item.Title
                    });
                }
                return(calendars);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Calendar Service - GetByCategories fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(null);
            }
        }
        public void AddUlsLoggerAddapter_SubscribesToEvents()
        {
            Mock <ILogger>        mockLogger  = new Mock <ILogger>();
            Mock <ILoggerFactory> mockFactory = new Mock <ILoggerFactory>();

            mockFactory.Setup(f => f.CreateLogger(It.IsAny <string>())).Returns(mockLogger.Object);

            new HostBuilder()
            .ConfigureServices(collection =>
            {
                collection
                .AddSingleton(mockFactory.Object)
                .AddUlsLoggerAddapter();
            })
            .Build()
            .Start();

            uint      eventId    = 1;
            Category  category   = new Category("Test");
            Level     logLevel   = Levels.Error;
            string    logMessage = "TestLogMessage";
            Exception exception  = new Exception();

            mockLogger.Invocations.Clear();
            ULSLogging.LogTraceTag(eventId, category, logLevel, logMessage);
            Assert.AreEqual(1, mockLogger.Invocations.Count, "ULSLogging.LogTraceTag not calling ILogger");

            mockLogger.Invocations.Clear();
            ULSLogging.ReportExceptionTag(eventId, category, exception, logMessage);
            Assert.AreEqual(1, mockLogger.Invocations.Count, "ULSLogging.ReportExceptionTag not calling ILogger");
        }
Exemple #10
0
        /// <summary>
        /// Get the file details for the specified resource
        /// </summary>
        /// <param name="resource">A resource to load</param>
        /// <returns>File datails</returns>
        private IResourceDetails GetFileDetails(IResource resource)
        {
            RetryPolicy  retryPolicy  = RetryPolicy ?? RetryPolicy.None;
            RetryCounter retryCounter = new RetryCounter(retryPolicy);
            int          iteration    = 0;
            Tuple <ResourceReadStatus, IResourceDetails> finalStatus = retryCounter.Run(
                () =>
            {
                iteration++;
                ULSLogging.LogTraceTag(0x238208cd /* tag_9669n */, Categories.ConfigurationDataSet, Levels.Verbose,
                                       "Attempting data set load for resource '{0}' in iteration '{1}' of '{2}'.",
                                       resource.Name, iteration, retryPolicy.RetryLimit);

                Tuple <ResourceReadStatus, IResourceDetails> status = resource.Read();
                return(Tuple.Create(status.Item1 == ResourceReadStatus.Success, status));
            });

            if (finalStatus.Item1 != ResourceReadStatus.Success)
            {
                ULSLogging.LogTraceTag(0x238208ce /* tag_9669o */, Categories.ConfigurationDataSet, Levels.Warning,
                                       "Failed to read resource '{0}' as the file read status is '{1}'.",
                                       resource.Name, finalStatus);
                return(null);
            }

            return(finalStatus.Item2);
        }
        /// <summary>
        /// An item was updated.
        /// </summary>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            try
            {
                base.ItemUpdated(properties);

                var siteURL = properties.WebUrl;
                var vehicleManagementDAL = new VehicleManagementDAL(siteURL);
                var ItemID      = properties.ListItemId;
                var currentItem = vehicleManagementDAL.GetByID(ItemID);
                if (currentItem.ApprovalStatus == "Cancelled")
                {
                    taskManagementDAL = new TaskManagementDAL(siteURL);
                    var tasks = taskManagementDAL.GetByItemID(currentItem.ID, StepModuleList.VehicleManagement.ToString()).ToList();
                    foreach (var task in tasks)
                    {
                        task.TaskStatus = TaskStatusList.Deferred;
                    }
                    taskManagementDAL.SaveItems(tasks);
                }
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA -  Transportation Event Receiver - ItemAdded fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
        }
        private void LoadHiddenFieldValues()
        {
            try
            {
                JavaScriptSerializer seriallizer = new JavaScriptSerializer();
                var foreignLanguages             = this.foreignLanguageDAL.GetAll();
                if (foreignLanguages != null && foreignLanguages.Count > 0)
                {
                    hdForeignLanguages.Value = seriallizer.Serialize(foreignLanguages);
                }

                var foreignLanguageLevels = this.foreignLanguageLevelDAL.GetAll();
                if (foreignLanguageLevels != null && foreignLanguageLevels.Count > 0)
                {
                    hdForeignLanguageLevels.Value = seriallizer.Serialize(foreignLanguageLevels);
                }

                hdNoneTemplateValue.Value = NoneTemplateValue;
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentFormUserControl: {ex.Message}");
            }
        }
        private void RecruitmentFormUserControl_OnAfterApproved(object sender, EventArgs e)
        {
            try
            {
                #region DEL 2017.09.27. Không cần IN. TFS #1586
                //var currentStep = this.CurrentItem[ApprovalFields.CurrentStep];
                //var additionalStep = this.CurrentItem[ApprovalFields.AdditionalStep];
                //var additionalDepartment = this.CurrentItem[ApprovalFields.AdditionalDepartment];
                //var status = ObjectHelper.GetString(this.CurrentItem[ApprovalFields.WFStatus]);

                //if ((currentStep == null) && (additionalStep != null) && (additionalDepartment != null) && (string.Compare(status, ApprovalStatus.Approved, true) != 0))
                //{
                //    RecruitmentTemplate RecruitmentTemplate = new RecruitmentTemplate(this.CurrentWeb, this.CurrentItem);
                //    string urlOfFileFormData = RecruitmentTemplate.ExportFormData();

                //    if (!string.IsNullOrEmpty(urlOfFileFormData))
                //    {
                //        string linkPrintEN = string.Format("<p>You can click on this <a href=\"{0}\">link<a/> to print form request.<p>", urlOfFileFormData);
                //        string linkPrintVN = string.Format("<p>Vui lòng truy vập vào <a href=\"{0}\">liên kết<a/> để in phiếu yêu cầu tuyển dụng.</p>", urlOfFileFormData);
                //        this.ApprovalBaseManagerObject.AdditionalInfoEmailObject[RecruitmentFormUserControl.PrintLinkEN_Key] = linkPrintEN;
                //        this.ApprovalBaseManagerObject.AdditionalInfoEmailObject[RecruitmentFormUserControl.PrintLinkVN_Key] = linkPrintVN;
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentFormUserControl: {ex.Message}");
            }
        }
        private void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (string.Compare(ddlTemplate.SelectedValue, NoneTemplateValue, true) != 0)
                {
                    lbtnDeleteTemplate.Visible = true;

                    // Load template info
                    int templateId = 0;
                    if (int.TryParse(ddlTemplate.SelectedValue, out templateId))
                    {
                        if (templateId > 0)
                        {
                            this.templateItem = this.CurrentList.GetItemById(templateId);
                        }
                    }
                }
                else
                {
                    lbtnDeleteTemplate.Visible = false;
                }

                LoadForm();
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentFormUserControl: {ex.Message}");
            }
        }
Exemple #15
0
        /// <summary>
        /// Attempts to load a new dataset and replaces the old one if load was successful
        /// </summary>
        /// <param name="arguments">The arguments for the update event.</param>
        protected virtual void UpdateLoadedDataSet(ResourceUpdatedEventArgs arguments)
        {
            RunExclusiveAction action = AllowMultipleThreadsLoadingDataSet ? m_action : s_action;

            action.Do(() =>
            {
                if (arguments.IsInitialLoad)
                {
                    ULSLogging.LogTraceTag(0x23821004 /* tag_967ae */, Categories.ConfigurationDataSet, Levels.Verbose,
                                           "Adding data set type '{0}' to cache.", typeof(T).Name);

                    if (Cache.GetOrAdd(typeof(IConfigurationDataSetLoader <T>),
                                       () => CreateCachedConfigurationDataSet(new CachedConfigurationDataSet <T>(DataSetOverride), arguments),
                                       out bool wasAdded) is CachedConfigurationDataSet <T> result && wasAdded)
                    {
                        OnLoad(result.LoadDetails);
                    }
                }
                else
                {
                    ULSLogging.LogTraceTag(0x23850399 /* tag_97qoz */, Categories.ConfigurationDataSet, Levels.Verbose,
                                           "Updating data set type '{0}' in cache.", typeof(T).Name);
                    CachedConfigurationDataSet <T> dataSets             = DataSets;
                    IList <ConfigurationDataSetLoadDetails> loadDetails = dataSets.LoadDetails;

                    if (Cache.AddOrUpdate(typeof(IConfigurationDataSetLoader <T>),
                                          () => CreateCachedConfigurationDataSet(dataSets, arguments),
                                          out bool wasUpdated) is CachedConfigurationDataSet <T> result && wasUpdated)
                    {
                        OnReload(loadDetails, result.LoadDetails);
                    }
                }
            });
        }
Exemple #16
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="file">File adaptor</param>
        /// <param name="folder">Folder</param>
        /// <param name="name">File Name including extension</param>
        public FileResource(IFile file, string folder, string name)
        {
            File   = Code.ExpectsArgument(file, nameof(file), TaggingUtilities.ReserveTag(0x238208d2 /* tag_9669s */));
            Folder = Code.ExpectsNotNullOrWhiteSpaceArgument(folder, nameof(folder), TaggingUtilities.ReserveTag(0x238208d3 /* tag_9669t */));
            Name   = Code.ExpectsNotNullOrWhiteSpaceArgument(name, nameof(name), TaggingUtilities.ReserveTag(0x238208d4 /* tag_9669u */));

            bool locationSet = false;

            try
            {
                if (!HasInvalidPathChars(Folder) && !HasInvalidPathChars(Name))
                {
                    Location    = Path.Combine(Folder, Name);
                    locationSet = true;
                }
                else
                {
                    ULSLogging.LogTraceTag(0x238208d5 /* tag_9669v */, Categories.ConfigurationDataSet, Levels.Error,
                                           "Failed to combine FileResource.Location for folder: '{0}', name: '{1}'", Folder, Name);
                }
            }
            catch (ArgumentException exception)
            {
                ULSLogging.ReportExceptionTag(0x238208d6 /* tag_9669w */, Categories.ConfigurationDataSet, exception,
                                              "Exception constructing FileResource for folder: '{0}', name: '{1}'", Folder, Name);
            }

            if (!locationSet)
            {
                Location = Name;
            }
        }
        /// <summary>
        /// An item is being added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            try
            {
                SPListItem curItem = properties.ListItem;

                var departmentRepo = new DepartmentDAL(properties.Site.Url);
                departmentRepo.CreateDepartmentSite(properties.SiteId, properties.Web.ID, curItem);

                // Add bod approver to BOD group
                var userBodString = Convert.ToString(properties.ListItem[StringConstant.DepartmentList.BODField]);
                if (!string.IsNullOrEmpty(userBodString))
                {
                    var employeeInfoRepo = new EmployeeInfoDAL(properties.Site.Url);
                    employeeInfoRepo.AddUserToGroup(properties.Site.ID, properties.Web.ID, curItem, StringConstant.Group.BODGroupName, userBodString);
                }
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - Department Event Receiver - ItemAdded fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
        }
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                if (!DelegationPermissionManager.DoesCurrentEmployeeHasDelegationPermission())
                {
                    SPUtility.HandleAccessDenied(new Exception(ResourceHelper.GetLocalizedString("AccessDeniedMessage", StringConstant.ResourcesFileWebPages, CultureInfo.CurrentUICulture.LCID)));
                }

                // Language
                this.isVietnameseLanguage = Page.LCID == PageLanguages.Vietnamese ? true : false;

                // Initialize objects
                InitObjects();

                // Initialize events
                InitEvents();

                // Initialize controls
                InitControls();
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }
        }
        public override void ItemAdding(SPItemEventProperties properties)
        {
            base.ItemAdding(properties);

            try
            {
                object fromDateObj = properties.AfterProperties[StringConstant.ChangeShiftList.FromDateField];
                if (fromDateObj != null)
                {
                    DateTime fromDate   = Convert.ToDateTime(fromDateObj);
                    DateTime reqDueDate = fromDate.Date;
                    //if (reqDueDate == DateTime.Now.Date)
                    //{
                    //    reqDueDate = reqDueDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                    //}
                    //else
                    //{
                    //    reqDueDate = reqDueDate.AddDays(-1).AddHours(23).AddMinutes(59).AddSeconds(59);
                    //}
                    reqDueDate = reqDueDate.AddHours(23).AddMinutes(59).AddSeconds(59);
                    properties.AfterProperties[StringConstant.CommonSPListField.CommonReqDueDateField] = reqDueDate.ToString(StringConstant.DateFormatTZForCAML);
                }
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - ChangeShiftEventReceiver - ItemAdding fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
            }
        }
        /// <summary>
        /// LoadWorkflowHistory
        /// </summary>
        /// <param name="workflowHistoryDAL">The WorkflowHistoryDAL object.</param>
        /// <param name="listName">The list name.</param>
        /// <param name="itemID">The current item id.</param>
        public void LoadWorkflowHistory(WorkflowHistoryDAL workflowHistoryDAL, string listName, int itemID)
        {
            try
            {
                var approvalBaseUserControl = this.Parent as ApprovalBaseUserControl;
                if (approvalBaseUserControl != null)
                {
                    if (approvalBaseUserControl.IsVietnameseLanguage)
                    {
                        this.gridViewWorkflowHistory.Columns[1].Visible = true;
                    }
                    else
                    {
                        this.gridViewWorkflowHistory.Columns[0].Visible = true;
                    }
                }

                List <Biz.Models.WorkflowHistory> workflowHistoryItems = GetWorkflowHistory(workflowHistoryDAL, listName, itemID);
                gridViewWorkflowHistory.DataSource = workflowHistoryItems;
                gridViewWorkflowHistory.DataBind();
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }
        }
        /// <summary>
        /// IsCurrrentEmployeeRecruitmentTeam
        /// </summary>
        /// <returns></returns>
        protected bool IsCurrrentEmployeeRecruitmentTeam()
        {
            var res = false;

            try
            {
                string queryString = string.Format(@"<Where>
                                                        <Eq>
                                                            <FieldRef Name='{0}' LookupId='True' />
                                                            <Value Type='Lookup'>{1}</Value>
                                                        </Eq>
                                                    </Where>", RecruitmentTeamList.Fields.Employees, this.CurrentEmployeeInfoObj.ID);

                var recruitmentTeamItems = this.recruitmentTeamDAL.GetByQuery(queryString);
                if (recruitmentTeamItems != null && recruitmentTeamItems.Count > 0)
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                ULSLogging.LogMessageToFile($"-- Error occurs on RecruitmentListUserControl: {ex.Message}");
            }

            return(res);
        }
Exemple #22
0
        /// <summary>
        /// Gets the experiment corresponding to the experimentName
        /// </summary>
        /// <param name="experimentName">The experiment name</param>
        /// <returns>the experiment</returns>
        public IExperiment GetExperiment(string experimentName)
        {
            if (!Code.ValidateNotNullOrWhiteSpaceArgument(experimentName, nameof(experimentName), TaggingUtilities.ReserveTag(0x23821085 /* tag_967cf */)))
            {
                return(null);
            }

            //This is to ensure threading
            IDictionary <string, IExperiment> temporaryReadDictionary = ExperimentsDictionary;

            if (temporaryReadDictionary == null)
            {
                ULSLogging.LogTraceTag(0x23821086 /* tag_967cg */, Categories.Experimentation, Levels.Error,
                                       "Experiment dictionary is being returned null");
                return(null);
            }

            if (!temporaryReadDictionary.ContainsKey(experimentName))
            {
                ULSLogging.LogTraceTag(0x23821087 /* tag_967ch */, Categories.Experimentation, Levels.Error,
                                       "Trying to get gates for an unknown experiment '{0}'", experimentName);
                return(null);
            }

            return(temporaryReadDictionary[experimentName]);
        }
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try
            {
                SPWeb web = (SPWeb)properties.Feature.Parent;
                SPSecurity.RunWithElevatedPrivileges(delegate
                {
                    using (SPSite site = new SPSite(web.Site.ID))
                    {
                        using (SPWeb currentWeb = site.OpenWeb())
                        {
                            if (web == null)
                            {
                                return;
                            }
                            GenerateLeftMenu(currentWeb);

                            CreateDepartmentSite(web);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }
        }
 /// <summary>
 /// Get all Shift Time
 /// </summary>
 /// <returns></returns>
 /// CALL URL: _vti_bin/Services/ShiftTime/ShiftTimeService.svc/GetShiftTimes
 public List <ShiftTimeModel> GetShiftTimes()
 {
     try
     {
         List <ShiftTimeModel> shiftTimes = new List <ShiftTimeModel>();
         var shiftTimeList = _shiftTimeDAL.GetShiftTimes();
         if (shiftTimeList.Any())
         {
             foreach (var item in shiftTimeList)
             {
                 shiftTimes.Add(
                     this.ConvertToShiftTimeModel(item)
                     );
             }
         }
         return(shiftTimes);
     }
     catch (Exception ex)
     {
         ULSLogging.Log(new SPDiagnosticsCategory("STADA - Shift Time Service - GetShiftTimes fn",
                                                  TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                        string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
         return(null);
     }
 }
        /// <summary>
        /// OnPreRender
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            try
            {
                base.OnPreRender(e);

                var approvalBaseUserControl = this.Parent as ApprovalBaseUserControl;
                if (approvalBaseUserControl != null)
                {
                    if (approvalBaseUserControl.CurrentFormMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)
                    {
                        this.txtComment.Enabled = false;
                        if (approvalBaseUserControl.WorkflowHistoryStyle == EWorkflowHistoryStyle.Simple)
                        {
                            this.txtComment.Visible = false;
                        }
                    }

                    if (approvalBaseUserControl.AllowPostComment)
                    {
                        this.txtComment.Enabled     = true;
                        this.btnPostComment.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }
        }
Exemple #26
0
        /// <summary>
        /// Get group users (email or deployment identifiers)
        /// </summary>
        /// <param name="groupName">Group name</param>
        /// <returns>List of user group emails or deployment ids</returns>
        public IEnumerable <string> GetGroupUsers(string groupName)
        {
            List <string> emptyList = new List <string>();

            if (string.IsNullOrWhiteSpace(groupName))
            {
                ULSLogging.LogCodeErrorTag(0x23821092 /* tag_967cs */, Categories.TestGroupsDataSet, false,
                                           false, "Null or empty group passed to TestGroupsDataSet.GetGroupUsers");
                return(emptyList);
            }

            if (m_groupUsers == null)
            {
                ULSLogging.LogCodeErrorTag(0x23821093 /* tag_967ct */, Categories.TestGroupsDataSet, false,
                                           false, "TestGroupsDataSet is not loaded.");
                return(emptyList);
            }

            string group = groupName.Trim();

            if (DefaultGroups.Contains(group))
            {
                return(m_userGroups.Keys.ToList());
            }

            if (m_groupUsers.TryGetValue(group, out List <string> groupUsers))
            {
                return(groupUsers);
            }

            return(emptyList);
        }
        public List <EmployeeModel> GetAllEmployees()
        {
            List <EmployeeModel> employees = new List <EmployeeModel>();

            try
            {
                var employeeList = _employeeInfoDAL.GetAll().Where(x => x.IsActive).OrderBy(y => y.FullName).ToList();
                foreach (var item in employeeList)
                {
                    employees.Add(new EmployeeModel
                    {
                        EmployeeID           = item.EmployeeID,
                        ID                   = item.ID,
                        Department           = LookupItemHelper.ConvertToModel(item.Department),
                        Location             = LookupItemHelper.ConvertToModel(item.FactoryLocation),
                        DepartmentPermission = item.DepartmentPermission,
                        FullName             = item.FullName,
                        EmployeeType         = item.EmployeeType
                    });
                }
                return(employees);
            }
            catch (Exception ex)
            {
                ULSLogging.Log(new SPDiagnosticsCategory("STADA - GetAllEmployees - GetManagerByDepartment fn",
                                                         TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected,
                               string.Format(CultureInfo.InvariantCulture, "{0}:{1}", ex.Message, ex.StackTrace));
                return(null);
            }
        }
Exemple #28
0
        /// <summary>
        /// Load the DataSet
        /// </summary>
        /// <param name="resources">Resources to load the DataSet from</param>
        /// <returns>true if load was successful, false otherwise</returns>
        public override bool Load(IDictionary <string, IResourceDetails> resources)
        {
            if (!base.Load(resources))
            {
                return(false);
            }

            bool resourceStatus = LoadResource(resources, TestGroupsResourceName, out byte[] file);

            if (!resourceStatus)
            {
                ULSLogging.LogCodeErrorTag(0x2382108f /* tag_967cp */, Categories.TestGroupsDataSet, false,
                                           true, "Failed to retrieve resource content for TestGroupsDataSet.");
            }
            else if (file == null || file.Length == 0)
            {
                ULSLogging.LogCodeErrorTag(0x23821090 /* tag_967cq */, Categories.TestGroupsDataSet, false,
                                           true, "Null or empty resource data encountered in TestGroupsDataSet loading method");
            }
            else
            {
                Load(file);
            }

            LastReload = DateTime.UtcNow;
            return(IsHealthy);
        }
        private void RequestForDiplomaSupplyApprovalManager_OnBeforeBuildBodyEmail(object sender, System.EventArgs e)
        {
            try
            {
                if (this.CurrentDepartment != null)
                {
                    var department = this.DepartmentDAL.GetByID(this.CurrentDepartment.LookupId);
                    if (department != null)
                    {
                        this.AdditionalInfoEmailObject[Requester_DepartmentName_EN] = department.Name;
                        this.AdditionalInfoEmailObject[Requester_DepartmentName_VN] = department.VietnameseName;
                    }

                    if (this.Creator != null)
                    {
                        if (this.Creator.EmployeePosition != null)
                        {
                            var employeePosition = this.EmployeePositionDAL.GetByID(this.Creator.EmployeePosition.LookupId);
                            if (employeePosition != null)
                            {
                                this.AdditionalInfoEmailObject[Requester_Position_EN] = employeePosition.Name;
                                this.AdditionalInfoEmailObject[Requester_Position_VN] = employeePosition.VietnameseName;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
            }
        }
Exemple #30
0
        /// <summary>
        /// btnCancelWorkflow_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnCancelWorkflow_Click(object sender, EventArgs e)
        {
            try
            {
                if (OnBeforeCancelWorkflow != null)
                {
                    OnBeforeCancelWorkflow(sender, e);
                }

                // Do Terminate
                approvalBaseManagerObject.Terminate();

                if (OnAfterCanceledWorkflow != null)
                {
                    OnAfterCanceledWorkflow(sender, e);
                }

                // Send Email
                approvalBaseManagerObject.SendEmail(EWorkflowAction.Terminate, this.commentBoxControlObject.ContentComment);

                // Post Comment
                approvalBaseManagerObject.PostComment(Status.CancelWorkflow, this.commentBoxControlObject.ContentComment);

                // Close Form.
                CloseForm(sender);
            }
            catch (Exception ex)
            {
                ULSLogging.LogError(ex);
                this.ShowClientMessage(ex.Message);
            }
        }