Example #1
0
        public IContract GetDCNDetails(IDictionary <string, string> objDict)
        {
            DCNContract        contract = new DCNContract();
            BELDataAccessLayer helper   = new BELDataAccessLayer();

            if (objDict != null && objDict.ContainsKey(Parameter.FROMNAME) && objDict.ContainsKey(Parameter.ITEMID) && objDict.ContainsKey(Parameter.USEREID))
            {
                string formName = objDict[Parameter.FROMNAME];
                int    itemId   = Convert.ToInt32(objDict[Parameter.ITEMID]);
                string userID   = objDict[Parameter.USEREID];
                IForm  dcnForm  = new DCNForm(true);
                dcnForm = helper.GetFormData(this.context, this.web, ApplicationNameConstants.DCRAPP, formName, itemId, userID, dcnForm);
                if (dcnForm != null && dcnForm.SectionsList != null && dcnForm.SectionsList.Count > 0)
                {
                    ////Print Button Hide not required for GET DCN Detail Method
                    ////var sectionDetails = dcnForm.SectionsList.FirstOrDefault(f => f.SectionName.Equals(DCNSectionName.DESIGNDOCUMENTENGINEERSECTION)) as DesignDocumentEngineerSection;
                    ////if (sectionDetails != null)
                    ////{
                    ////    if (itemId != 0)
                    ////    {
                    ////        if ((sectionDetails.Status == FormStatus.COMPLETED || sectionDetails.Status == FormStatus.REJECTED) && sectionDetails.ApproversList.Any(p => p.Role == DCNRoles.DCRPROCESSINCHARGE && p.Approver != userID))
                    ////        {
                    ////            if (dcnForm.Buttons.FirstOrDefault(p => p.Name == "Print") != null)
                    ////            {
                    ////                dcnForm.Buttons.FirstOrDefault(p => p.Name == "Print").IsVisible = false;
                    ////            }
                    ////        }
                    ////    }
                    ////}
                    contract.Forms.Add(dcnForm);
                }
            }
            return(contract);
        }
Example #2
0
        public DCNAdminContract GetDCNAdminDetails(IDictionary <string, string> objDict)
        {
            DCNAdminContract   contract = new DCNAdminContract();
            BELDataAccessLayer helper   = new BELDataAccessLayer();

            if (objDict != null && objDict.ContainsKey(Parameter.FROMNAME) && objDict.ContainsKey(Parameter.ITEMID) && objDict.ContainsKey(Parameter.USEREID))
            {
                string formName     = objDict[Parameter.FROMNAME];
                int    itemId       = Convert.ToInt32(objDict[Parameter.ITEMID]);
                string userID       = objDict[Parameter.USEREID];
                IForm  dcnAdminForm = new DCNAdminForm(true);
                dcnAdminForm = helper.GetFormData(this.context, this.web, ApplicationNameConstants.DCRAPP, formName, itemId, userID, dcnAdminForm);
                if (dcnAdminForm != null && dcnAdminForm.SectionsList != null && dcnAdminForm.SectionsList.Count > 0)
                {
                    var sectionDetails = dcnAdminForm.SectionsList.FirstOrDefault(f => f.SectionName.Equals(DCNSectionName.DCNDETAILADMINSECTION)) as DCNDetailAdminSection;
                    if (sectionDetails != null)
                    {
                        if (itemId != 0)
                        {
                            if ((sectionDetails.Status == FormStatus.COMPLETED || sectionDetails.Status == FormStatus.REJECTED) && !sectionDetails.ApproversList.Any(p => (p.Role == DCNRoles.DCRPROCESSINCHARGE || p.Role == DCNRoles.SCM) && !String.IsNullOrEmpty(p.Approver) && p.Approver.Split(',').Contains(userID.Trim())))
                            {
                                if (dcnAdminForm.Buttons.FirstOrDefault(p => p.Name == "Print") != null)
                                {
                                    dcnAdminForm.Buttons.FirstOrDefault(p => p.Name == "Print").IsVisible = false;
                                }
                            }
                        }
                    }
                    contract.Forms.Add(dcnAdminForm);
                }
            }
            return(contract);
        }
Example #3
0
        /// <summary>
        /// Download File
        /// </summary>
        /// <param name="url">URL</param>
        /// <param name="applicationName">application Name</param>
        /// <returns>Byte Array</returns>
        public byte[] DownloadFile(string url, string applicationName)
        {
            BELDataAccessLayer helper = new BELDataAccessLayer();

            ////string siteURL = helper.GetSiteURL(applicationName);
            ////context = helper.CreateClientContext(siteURL);
            return(helper.GetFileBytesByUrl(this.context, url));
        }
Example #4
0
        /// <summary>
        /// Download File
        /// </summary>
        /// <param name="url">URL</param>
        /// <param name="applicationName">application Name</param>
        /// <returns>Byte Array</returns>
        public byte[] DownloadFile(string url, string applicationName)
        {
            BELDataAccessLayer helper = new BELDataAccessLayer();
            ////string siteURL = helper.GetSiteURL(applicationName);
            ////context = helper.CreateClientContext(siteURL);
            ClientContext contexts = null;
            string        siteURL  = helper.GetSiteURL(SiteURLs.ITEMCODECREATIONSITEURL);

            if (!string.IsNullOrEmpty(siteURL))
            {
                contexts = BELDataAccessLayer.Instance.CreateClientContextforattachment(siteURL);
            }

            return(helper.GetFileBytesByUrl(contexts, url));
        }
Example #5
0
        public List <ISection> RetrieveWIPDCR(IDictionary <string, string> objDict)
        {
            Dictionary <string, string> otherParamDictionary = null;
            BELDataAccessLayer          helper   = new BELDataAccessLayer();
            List <ISection>             sections = new List <ISection>();

            if (objDict != null && objDict.ContainsKey("UserEmail"))
            {
                string userEmail = objDict["UserEmail"];
                string formName  = string.Empty;
                //IForm form = new WIPDCRForm(true);
                WIPDCRDetailsSection section = new WIPDCRDetailsSection(true);
                sections = helper.GetItemsForSection(this.context, this.web, ApplicationNameConstants.DCRAPP, formName, (ISection)section, userEmail, otherParamDictionary);
            }
            return(sections);
        }
Example #6
0
        private CommonBusinessLayer()
        {
            BELDataAccessLayer helper  = new BELDataAccessLayer();
            string             siteURL = helper.GetSiteURL(SiteURLs.DCRDCNSITEURL);

            if (!string.IsNullOrEmpty(siteURL))
            {
                if (this.context == null)
                {
                    this.context = BELDataAccessLayer.Instance.CreateClientContext(siteURL);
                }
                if (this.web == null)
                {
                    this.web = BELDataAccessLayer.Instance.CreateWeb(this.context);
                }
            }
        }
Example #7
0
 protected BusinessLayerBase()
 {
     try
     {
         BELDataAccessLayer helper  = new BELDataAccessLayer();
         string             siteURL = helper.GetSiteURL(SiteURLs.DCRDCNSITEURL);
         if (!string.IsNullOrEmpty(siteURL))
         {
             context = helper.CreateClientContext(siteURL);
             web     = helper.CreateWeb(context);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Example #8
0
        public ActionStatus SaveBySection(ISection sectionDetails, Dictionary <string, string> objDict)
        {
            lock (Padlock)
            {
                ActionStatus status       = new ActionStatus();
                DCRNoCount   currentDCRNo = null;
                //BELDataAccessLayer helper = new BELDataAccessLayer();
                if (sectionDetails != null && objDict != null)
                {
                    objDict[Parameter.ACTIVITYLOG]     = DCRDCNListNames.DCRACTIVITYLOG;
                    objDict[Parameter.APPLICATIONNAME] = ApplicationNameConstants.DCRAPP;
                    objDict[Parameter.FROMNAME]        = FormNameConstants.DCRFORM;
                    DCRDetailSection      section          = null;
                    DesignEngineerSection designEngSection = null;
                    if (sectionDetails.SectionName == DCRSectionName.DCRDETAILSECTION)
                    {
                        section = sectionDetails as DCRDetailSection;
                        if (string.IsNullOrEmpty(section.DCRNo) && sectionDetails.ActionStatus == ButtonActionStatus.SaveAsDraft)
                        {
                            section.Title = section.DCRNo = "View";
                        }
                        else if (sectionDetails.ActionStatus == ButtonActionStatus.NextApproval && (string.IsNullOrEmpty(section.DCRNo) || section.DCRNo == "View"))
                        {
                            ////section = sectionDetails as DCRDetailSection;
                            currentDCRNo        = GetDCRNo(section.BusinessUnit);
                            section.RequestDate = DateTime.Now;
                            if (currentDCRNo != null)
                            {
                                currentDCRNo.CurrentValue = currentDCRNo.CurrentValue + 1;
                                Logger.Info("DCR Current Value + 1 = " + currentDCRNo.CurrentValue);
                                section.DCRNo = string.Format("DCR-{0}-{1}-{2}", currentDCRNo.BusinessUnit, DateTime.Today.Year, string.Format("{0:0000}", currentDCRNo.CurrentValue));
                                section.Title = section.DCRNo;
                                Logger.Info("DCR No is " + section.DCRNo);
                                status.ExtraData = section.DCRNo;
                            }
                        }
                    }
                    if (sectionDetails.SectionName == DCRSectionName.DESIGNENGINEERSECTION && sectionDetails.ActionStatus == ButtonActionStatus.NextApproval)
                    {
                        designEngSection = sectionDetails as DesignEngineerSection;
                        if (designEngSection != null)
                        {
                            designEngSection.FinalDesignEngineer = objDict[Parameter.USEREID];
                        }
                    }
                    List <ListItemDetail> objSaveDetails = BELDataAccessLayer.Instance.SaveData(this.context, this.web, sectionDetails, objDict);
                    ListItemDetail        itemDetails    = objSaveDetails.Where(p => p.ListName.Equals(DCRDCNListNames.DCRLIST)).FirstOrDefault <ListItemDetail>();
                    if (sectionDetails.SectionName == DCRSectionName.DCRDETAILSECTION)
                    {
                        if (section != null && !string.IsNullOrEmpty(section.OldDCRNo))
                        {
                            Dictionary <string, dynamic> values = new Dictionary <string, dynamic>();
                            values.Add("IsDCRRetrieved", true);
                            BELDataAccessLayer.Instance.SaveFormFields(this.context, this.web, DCRDCNListNames.DCRLIST, section.OldDCRId, values);
                        }

                        if (itemDetails.ItemId > 0 && currentDCRNo != null)
                        {
                            //// AsyncHelper.Call(obj =>
                            ////  {
                            UpdateDCRNoCount(currentDCRNo);
                            Logger.Info("Update DCR No " + section.DCRNo);
                            ////  });
                        }
                    }

                    if (sectionDetails.SectionName == DCRSectionName.DESIGNENGINEERSECTION && sectionDetails.ActionStatus == ButtonActionStatus.NextApproval)
                    {
                        if (designEngSection != null && designEngSection.DateForCompletionOfTesting != null && designEngSection.DateForReceiptOfSamples != null)
                        {
                            EmailHelper eHelper = new EmailHelper();

                            Dictionary <string, string> mailCustomValues = null; List <FileDetails> emailAttachments = null;
                            Dictionary <string, string> email = new Dictionary <string, string>();
                            List <ListItemDetail>       itemdetail = new List <ListItemDetail>();
                            string applicationName = ApplicationNameConstants.DCRAPP; string formName = FormNameConstants.DCRFORM;

                            string from = string.Empty, to = string.Empty, cc = string.Empty, role = string.Empty, tmplName = string.Empty;
                            from = objDict[Parameter.USEREID];
                            from = BELDataAccessLayer.GetEmailUsingUserID(context, web, from);
                            to   = designEngSection.ProposedBy;
                            to   = BELDataAccessLayer.GetEmailUsingUserID(context, web, to);

                            cc       = from;
                            role     = DCRRoles.DESIGNENGINEER;
                            tmplName = EmailTemplateName.DESIGNENGGTOCREATOR;
                            itemdetail.Add(new ListItemDetail()
                            {
                                ItemId = itemDetails.ItemId, IsMainList = true, ListName = DCRDCNListNames.DCRLIST
                            });
                            if (mailCustomValues == null)
                            {
                                mailCustomValues = new Dictionary <string, string>();
                            }
                            mailCustomValues[Parameter.CURRENTAPPROVERNAME] = BELDataAccessLayer.GetNameUsingUserID(context, web, objDict[Parameter.USEREID]);

                            email = eHelper.GetEmailBody(context, web, tmplName, itemdetail, mailCustomValues, role, applicationName, formName);
                            eHelper.SendMail(applicationName, formName, tmplName, email["Subject"], email["Body"], from, to, cc, false, emailAttachments);
                        }
                    }

                    if (itemDetails.ItemId > 0)
                    {
                        status.IsSucceed = true;
                        status.ItemID    = itemDetails.ItemId;
                        switch (sectionDetails.ActionStatus)
                        {
                        case ButtonActionStatus.SaveAsDraft:
                            status.Messages.Add("Text_SaveDraftSuccess");
                            break;

                        case ButtonActionStatus.SaveAndNoStatusUpdate:
                            status.Messages.Add("Text_SaveSuccess");
                            break;

                        case ButtonActionStatus.NextApproval:
                            status.Messages.Add(ApplicationConstants.SUCCESSMESSAGE);
                            break;

                        case ButtonActionStatus.Delegate:
                            status.Messages.Add("Text_DelegatedSuccess");
                            break;

                        case ButtonActionStatus.Complete:
                            status.Messages.Add("Text_CompleteSuccess");
                            break;

                        case ButtonActionStatus.Rejected:
                            status.Messages.Add("Text_RejectedSuccess");
                            break;

                        default:
                            status.Messages.Add(ApplicationConstants.SUCCESSMESSAGE);
                            break;
                        }
                    }
                    else
                    {
                        status.IsSucceed = false;
                        status.Messages.Add(ApplicationConstants.ERRORMESSAGE);
                    }
                }
                return(status);
            }
        }
Example #9
0
        /// <summary>
        /// Validates the users.
        /// </summary>
        /// <param name="emailList">The email list.</param>
        /// <returns>list of invalid users</returns>
        public List <string> ValidateUsers(List <string> emailList)
        {
            BELDataAccessLayer helper = new BELDataAccessLayer();

            return(helper.GetInvalidUsers(emailList));
        }
Example #10
0
 public User getCurrentUser(string userid)
 {
     return(BELDataAccessLayer.EnsureUser(this.context, this.web, userid));
 }
Example #11
0
        /// <summary>
        /// Sets the tran properties REST.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="web">The web.</param>
        /// <param name="listItem">The list item.</param>
        /// <param name="tranItem">The tran item.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="getSubItems">if set to <c>true</c> [get sub items].</param>
        /// <returns>
        /// Transaction item
        /// </returns>
        private ITrans SetTranPropertiesREST(ClientContext context, Web web, JToken listItem, ITrans tranItem, PropertyInfo[] properties, bool getSubItems = true)
        {
            BELDataAccessLayer helper = new BELDataAccessLayer();

            foreach (PropertyInfo property in properties)
            {
                try
                {
                    bool   isListColumn  = property.GetCustomAttribute <IsListColumnAttribute>() == null || property.GetCustomAttribute <IsListColumnAttribute>().IsListColumn;
                    bool   isTask        = property.GetCustomAttribute <IsTaskAttribute>() != null && property.GetCustomAttribute <IsTaskAttribute>().IsTaskField;
                    bool   isTran        = property.GetCustomAttribute <IsTranAttribute>() != null && property.GetCustomAttribute <IsTranAttribute>().IsTranField;
                    string listCoumnName = property.GetCustomAttribute <FieldColumnNameAttribute>() != null && !string.IsNullOrEmpty(property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation) ? property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation : property.Name;
                    bool   isFile        = property.GetCustomAttribute <IsFileAttribute>() != null && property.GetCustomAttribute <IsFileAttribute>().IsFile;
                    if (isListColumn)
                    {
                        if (property.GetCustomAttribute <FieldColumnNameAttribute>() != null && property.GetCustomAttribute <FieldColumnNameAttribute>().IsLookup)
                        {
                            string lookupFieldName = property.GetCustomAttribute <FieldColumnNameAttribute>().LookupFieldNameForTrans;
                            if (property.GetCustomAttribute <FieldColumnNameAttribute>().IsMultipleLookup)
                            {
                                if (((JContainer)listItem[listCoumnName])["results"] != null)
                                {
                                    List <string> reletedto = new List <string>();
                                    foreach (dynamic lookup in ((JContainer)listItem[listCoumnName])["results"])
                                    {
                                        reletedto.Add(lookup[lookupFieldName].ToString());
                                    }
                                    property.SetValue(tranItem, reletedto);
                                }
                            }
                            else
                            {
                                if (((dynamic)listItem[listCoumnName])[lookupFieldName] != null)
                                {
                                    object value     = ((JValue)((dynamic)listItem[listCoumnName])[lookupFieldName]).Value;
                                    Type   t         = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
                                    object safeValue = (value == null) ? null : Convert.ChangeType(value, t);
                                    property.SetValue(tranItem, safeValue);
                                }
                            }
                        }
                        else if (property.GetCustomAttribute <IsPersonAttribute>() != null && property.GetCustomAttribute <IsPersonAttribute>().IsPerson)
                        {
                            if (property.GetCustomAttribute <IsPersonAttribute>().IsPerson)
                            {
                                string personEmail = string.Empty;
                                if (property.GetCustomAttribute <IsPersonAttribute>().ReturnID)
                                {
                                    if (((JContainer)listItem[listCoumnName])["results"] != null)
                                    {
                                        foreach (dynamic person in ((JContainer)listItem[listCoumnName])["results"])
                                        {
                                            personEmail = personEmail.Trim(',') + "," + person["EMail"].ToString();
                                        }
                                    }
                                }
                                else
                                {
                                    if (((dynamic)listItem[listCoumnName]).EMail != null)
                                    {
                                        personEmail = ((dynamic)listItem[listCoumnName])["EMail"].ToString();
                                    }
                                }
                                property.SetValue(tranItem, personEmail.Trim(','));
                            }
                            else if (property.GetCustomAttribute <IsPersonAttribute>().ReturnName)
                            {
                                string personEmail = string.Empty;
                                if (property.GetCustomAttribute <IsPersonAttribute>().IsMultiple)
                                {
                                    if (((JContainer)listItem[listCoumnName])["results"] != null)
                                    {
                                        foreach (dynamic person in ((JContainer)listItem[listCoumnName])["results"])
                                        {
                                            personEmail = personEmail.Trim(',') + "," + person["Title"].ToString();
                                        }
                                    }
                                }
                                else
                                {
                                    if (((dynamic)listItem[listCoumnName]).Title != null)
                                    {
                                        personEmail = ((dynamic)listItem[listCoumnName])["Title"].ToString();
                                    }
                                }
                                property.SetValue(tranItem, personEmail.Trim(','));
                            }
                        }
                        else if (isFile)
                        {
                            if (((dynamic)((dynamic)listItem["AttachmentFiles"])).__deferred != null)
                            {
                                string             url = ((dynamic)((dynamic)listItem["AttachmentFiles"])).__deferred.uri.Value;
                                List <FileDetails> objAttachmentFiles = helper.GetAttachmentsUsingREST(url);
                                property.SetValue(tranItem, objAttachmentFiles);
                            }
                        }
                        else
                        {
                            object value     = ((JValue)listItem[listCoumnName]).Value;
                            Type   t         = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
                            object safeValue = (value == null) ? null : Convert.ChangeType(value, t);
                            property.SetValue(tranItem, safeValue);
                        }
                    }
                    else if (isTran)
                    {
                        if (getSubItems)
                        {
                            string listName = property.GetCustomAttribute <IsTranAttribute>().TranListName;
                            Type   tSubTran = property.GetCustomAttribute <IsTranAttribute>().TranType;
                            if (!string.IsNullOrEmpty(listName))
                            {
                                List <ITrans> subTrans = this.GetTransactionListData(context, web, tSubTran, listName, Convert.ToInt32(listItem["ID"]));
                                property.SetValue(tranItem, subTrans);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(string.Format("Error While Save tran Item  - Message:{0}, StackTrace: {1}", ex.Message, ex.StackTrace));
                }
            }
            return(tranItem);
        }
Example #12
0
        /// <summary>
        /// Saves the by section.
        /// </summary>
        /// <param name="sections">The sections.</param>
        /// <param name="objDict">The object dictionary.</param>
        /// <returns>return status</returns>
        public ActionStatus SaveBySection(ISection sectionDetails, Dictionary <string, string> objDict)
        {
            ActionStatus status = new ActionStatus();

            BELDataAccessLayer helper = new BELDataAccessLayer();

            if (sectionDetails != null && objDict != null)
            {
                objDict[Parameter.ACTIVITYLOG]     = DCRDCNListNames.DCNACTIVITYLOG;
                objDict[Parameter.APPLICATIONNAME] = ApplicationNameConstants.DCRAPP;
                objDict[Parameter.FROMNAME]        = FormNameConstants.DCNFORM;
                DesignEngineerSection section = null;
                if (sectionDetails.SectionName == DCNSectionName.DESIGNENGINEERSECTION)
                {
                    if (sectionDetails.ListDetails != null && sectionDetails.ListDetails.Count != 0 && sectionDetails.ListDetails[0].ItemId == 0)
                    {
                        section = sectionDetails as DesignEngineerSection;
                        if (ISDCNGenerataed(section.DCRNo))
                        {
                            status.IsSucceed = false;
                            status.Messages.Add("Text_IsDCNGenerated");
                            return(status);
                        }
                    }
                }

                List <ListItemDetail> objSaveDetails = helper.SaveData(this.context, this.web, sectionDetails, objDict);
                ListItemDetail        itemDetails    = objSaveDetails.Where(p => p.ListName.Equals(DCRDCNListNames.DCNLIST)).FirstOrDefault <ListItemDetail>();
                if (sectionDetails.SectionName == DCNSectionName.DESIGNENGINEERSECTION)
                {
                    if (sectionDetails.ListDetails != null && sectionDetails.ListDetails.Count != 0 && sectionDetails.ListDetails[0].ItemId == 0)
                    {
                        //var sectiondcn = sectionDetails as DesignDocumentEngineerSection;
                        Dictionary <string, dynamic> values = new Dictionary <string, dynamic>();
                        values.Add("DCNNo", section.DCNNo);
                        values.Add("IsDCNGenerated", "1");
                        BELDataAccessLayer.Instance.SaveFormFields(this.context, this.web, DCRDCNListNames.DCRLIST, section.DCRID, values);
                        status.ExtraData = section.DCNNo;
                    }
                }

                if (itemDetails.ItemId > 0)
                {
                    status.ItemID    = itemDetails.ItemId;
                    status.IsSucceed = true;
                    switch (sectionDetails.ActionStatus)
                    {
                    case ButtonActionStatus.SaveAsDraft:
                        status.Messages.Add("Text_SaveDraftSuccess");
                        break;

                    case ButtonActionStatus.SaveAndNoStatusUpdate:
                        status.Messages.Add("Text_SaveSuccess");
                        break;

                    case ButtonActionStatus.NextApproval:
                        status.Messages.Add(ApplicationConstants.SUCCESSMESSAGE);
                        break;

                    case ButtonActionStatus.Complete:
                        status.Messages.Add("Text_CompleteSuccess");
                        break;

                    case ButtonActionStatus.SendBack:
                        status.Messages.Add("Text_SendBackSuccess");
                        break;

                    default:
                        status.Messages.Add(ApplicationConstants.SUCCESSMESSAGE);
                        break;
                    }
                }
                else
                {
                    status.IsSucceed = false;
                    status.Messages.Add(ApplicationConstants.ERRORMESSAGE);
                }
            }
            return(status);
        }
Example #13
0
        /// <summary>
        /// Gets the DCN details.
        /// </summary>
        /// <param name="objDict">The object dictionary.</param>
        /// <returns>byte array</returns>
        public List <DCRDetails> RetrieveAllDCRNos(IDictionary <string, string> objDict)
        {
            List <DCRDetails> dcrs = new List <DCRDetails>();
            List      spList       = this.web.Lists.GetByTitle(DCRDCNListNames.DCRLIST);
            CamlQuery query        = new CamlQuery();

            if (objDict != null && objDict.ContainsKey("UserEmail"))
            {
                User loggedinuser = BELDataAccessLayer.EnsureUser(context, web, objDict["UserEmail"].ToString());
                query.ViewXml = @"<View>
                                        <Query>
                                                  <Where>
                                                        <And>
                                                            <Eq>
                                                                    <FieldRef Name='FinalDesignEngineer' /><Value Type='User'>" + loggedinuser.Title + @"</Value>
                                                            </Eq>
                                                        <And>
                                                            <Eq>
                                                                    <FieldRef Name='Status' />
                                                                    <Value Type='Text'>" + FormStatus.COMPLETED + @"</Value>
                                                            </Eq>
                                                            <Eq>
                                                                    <FieldRef Name='IsDCNGenerated' />
                                                                    <Value Type='Boolean'>0</Value>
                                                            </Eq>
                                                    </And>
                                                   </And>
                                                 </Where>
                                        </Query>
                            </View>";
            }
            else
            {
                query.ViewXml = @"<View>
                                                        <Query>
                                                                  <Where>
                                                                    <And>
                                                                      <Eq>
                                                                            <FieldRef Name='Status' />
                                                                            <Value Type='Text'>" + FormStatus.COMPLETED + @"</Value>
                                                                       </Eq>
                                                                       <Eq>
                                                                             <FieldRef Name='IsDCNGenerated' />
                                                                             <Value Type='Boolean'>0</Value>
                                                                       </Eq>
                                                                    </And>
                                                                 </Where>
                                                        </Query>
                                            </View>";
            }
            //  query.ViewXml = @"<View><ViewFields><FieldRef Name='ID' /><FieldRef Name='DCRNo' /><FieldRef Name='ProductName' /><FieldRef Name='RequestDate' /><FieldRef Name='ProposedBy' /></ViewFields></View>";
            ListItemCollection items = spList.GetItems(query);

            this.context.Load(items);
            this.context.ExecuteQuery();
            if (items != null && items.Count != 0)
            {
                foreach (ListItem item in items)
                {
                    DCRDetails dcr = new DCRDetails();
                    dcr.DCRNo = Convert.ToString(item["DCRNo"]);
                    dcr.ID    = item.Id;
                    FieldUserValue user = item["ProposedBy"] as FieldUserValue;
                    dcr.ProposedBy  = BELDataAccessLayer.GetNameFromPersonField(context, web, user);
                    dcr.ProductName = Convert.ToString(item["ProductName"]);
                    dcr.RequestDate = Convert.ToDateTime(item["RequestDate"]);
                    dcrs.Add(dcr);
                }
            }
            return(dcrs);
        }
Example #14
0
        /// <summary>
        /// Gets the report details.
        /// </summary>
        /// <param name="report">The report.</param>
        /// <returns>
        /// list of Reportdetails
        /// </returns>
        public List <ReportDetails> GetReportDetails(Report report)
        {
            try
            {
                List <ReportDetails> reportList = new List <ReportDetails>();
                string appendStatusClause = string.Empty, appendWhereClause = string.Empty, startStatusAndClause = string.Empty, endStatusAndClause = string.Empty, startAndClause = string.Empty, endAndClause = string.Empty;
                if (report != null)
                {
                    string   fromDate    = string.Format("{0:yyyy-MM-dd}", report.FromDate);
                    string   toDate      = string.Format("{0:yyyy-MM-dd}", report.ToDate);
                    string   pendingWith = report.PendingWith;
                    string[] arrFilter   = !string.IsNullOrWhiteSpace(pendingWith) ? pendingWith.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries) : null;

                    string   status          = report.Status;
                    string[] arrStatusFilter = !string.IsNullOrWhiteSpace(status) ? status.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries) : null;

                    List statusList = this.web.Lists.GetByTitle(ICCPListNames.ICCPMAINLIST);
                    if (statusList != null)
                    {
                        CamlQuery query = new CamlQuery();

                        //if (!string.IsNullOrWhiteSpace(report.Status))
                        //{
                        //    startStatusAndClause = "<And>";
                        //    EndStatusAndClause = "</And>";
                        //    appendStatusClause = @"<Eq>
                        //                               <FieldRef Name='Status' />
                        //                               <Value Type='Text'>" + report.Status + @"</Value>
                        //                            </Eq>";
                        //}

                        string paraStatusValue = string.Empty;
                        if (arrStatusFilter != null)
                        {
                            foreach (string item in arrStatusFilter)
                            {
                                paraStatusValue += "<Value Type='Text'>" + item + @"</Value>";
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(paraStatusValue))
                        {
                            startStatusAndClause = "<And>";
                            endStatusAndClause   = "</And>";

                            appendStatusClause = @"<In>
                                                    <FieldRef Name='Status' />
                                                    <Values>
                                                    " + paraStatusValue + @"
                                                    </Values>
                                                </In>";
                        }

                        string paraValue = string.Empty;
                        if (arrFilter != null)
                        {
                            foreach (string item in arrFilter)
                            {
                                paraValue += "<Value Type='Text'>" + item + @"</Value>";
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(paraValue))
                        {
                            if (string.IsNullOrWhiteSpace(report.Status))
                            {
                                startStatusAndClause = "<And>";
                                endStatusAndClause   = "</And>";
                            }
                            else
                            {
                                startAndClause = "<And>";
                                endAndClause   = "</And>";
                            }
                            appendWhereClause = @"<In>
                                                    <FieldRef Name='PendingWith' />
                                                    <Values>
                                                    " + paraValue + @"
                                                    </Values>
                                                </In>";
                        }

                        query.ViewXml = @"<View>
                                        <Query> 
                                            <Where>
                                                <And>
                                                     <Geq>
                                                        <FieldRef Name='RequestDate' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>" + fromDate + @"</Value>
                                                     </Geq>
                                                     " + startStatusAndClause + @"
                                                        <Leq>
                                                           <FieldRef Name='RequestDate' />
                                                           <Value IncludeTimeValue='FALSE' Type='DateTime'>" + toDate + @"</Value>
                                                        </Leq>
                                                       " + startAndClause + @"
                                                      " + appendStatusClause + @"
                                                      " + appendWhereClause + @"
                                                     " + endAndClause + @"
                                                    " + endStatusAndClause + @"
                                                  </And>
                                               </Where>                                                                                   
                                            <OrderBy>
                                                <FieldRef Name='ID' Ascending='True' />
                                            </OrderBy>                                            
                                        </Query>                                      
                                    </View>";
                        ListItemCollection items = statusList.GetItems(query);
                        this.context.Load(items);
                        this.context.ExecuteQuery();

                        if (items != null && items.Count > 0)
                        {
                            foreach (ListItem item in items)
                            {
                                ReportDetails reportDetails = new ReportDetails();
                                reportDetails.ICCPNo          = Convert.ToString(item["Title"]);
                                reportDetails.ItemCode        = Convert.ToString(item["ItemCode"]);
                                reportDetails.ItemDescription = Convert.ToString(item["ItemDescription"]);
                                reportDetails.BuyMake         = Convert.ToString(item["BuyMake"]);
                                reportDetails.CostPrice       = Convert.ToString(item["CostPrice"]);
                                reportDetails.GSTRate         = Convert.ToString(item["GSTRate"]);
                                reportDetails.PendingWith     = Convert.ToString(item["PendingWith"]);
                                reportDetails.ProductGroup    = Convert.ToString(item["ProductGroup"]);
                                reportDetails.Quantity        = Convert.ToString(item["Quantity"]);
                                reportDetails.Status          = Convert.ToString(item["Status"]);
                                if (!string.IsNullOrWhiteSpace(reportDetails.Status))
                                {
                                    switch (reportDetails.Status.ToLower())
                                    {
                                    case "submitted":
                                        reportDetails.Status = "Pending";
                                        break;

                                    case "sent back":
                                        reportDetails.Status = "Rework";
                                        break;
                                    }
                                }
                                reportDetails.TypeofPackaging = Convert.ToString(item["TypeOfPackaging"]);
                                reportDetails.CreatedBy       = BELDataAccessLayer.GetPersonValueFromPersonField(this.context, this.web, (FieldUserValue)item["ProposedBy"], Person.Name);
                                reportDetails.CreatedDate     = Convert.ToString(item["RequestDate"]);
                                reportList.Add(reportDetails);
                            }
                        }
                    }
                }
                reportList.RemoveAll(m => m.Status == "Draft");
                return(reportList);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.StackTrace);
                return(null);
            }
        }
Example #15
0
        /// <summary>
        /// Assigns the property values.
        /// </summary>
        /// <param name="objMaster">The object master.</param>
        /// <param name="context">The context.</param>
        /// <param name="web">The web.</param>
        /// <param name="items">The items.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <returns>
        /// master object
        /// </returns>
        private IMaster AssignPropertyValues(dynamic objMaster, ClientContext context, Web web, ListItemCollection items, Type itemType)
        {
            List <IMasterItem> masterItems = new List <IMasterItem>();

            foreach (ListItem item in items)
            {
                dynamic        listItem       = Activator.CreateInstance(itemType);
                PropertyInfo[] itemProperties = listItem.GetType().GetProperties();
                foreach (PropertyInfo property in itemProperties)
                {
                    if (property.GetCustomAttribute <FieldColumnNameAttribute>() != null && !string.IsNullOrEmpty(property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation))
                    {
                        if (property.GetCustomAttribute <IsPersonAttribute>() != null && property.GetCustomAttribute <IsPersonAttribute>().IsPerson&& property.GetCustomAttribute <IsPersonAttribute>().ReturnID)
                        {
                            if (item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] is FieldUserValue[])
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetUserIDsFromPersonField(context, web, (FieldUserValue[])item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation]));
                            }
                            else
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetUserIDsFromPersonField(context, web, (FieldUserValue)item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation]));
                            }
                        }
                        else if (property.GetCustomAttribute <IsPersonAttribute>() != null && property.GetCustomAttribute <IsPersonAttribute>().IsPerson&& property.GetCustomAttribute <IsPersonAttribute>().ReturnName)
                        {
                            if (item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] is FieldUserValue[])
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetPersonValueFromPersonField(context, web, (FieldUserValue[])item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation], Person.Name));
                            }
                            else
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetPersonValueFromPersonField(context, web, (FieldUserValue)item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation], Person.Name));
                            }
                        }
                        else if (property.GetCustomAttribute <IsPersonAttribute>() != null && property.GetCustomAttribute <IsPersonAttribute>().IsPerson&& property.GetCustomAttribute <IsPersonAttribute>().ReturnAlias)
                        {
                            if (item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] is FieldUserValue[])
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetPersonValueFromPersonField(context, web, (FieldUserValue[])item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation], Person.Alias));
                            }
                            else
                            {
                                property.SetValue(listItem, BELDataAccessLayer.GetPersonValueFromPersonField(context, web, (FieldUserValue)item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation], Person.Alias));
                            }
                        }
                        else if (property.GetCustomAttribute <FieldColumnNameAttribute>().IsLookup)
                        {
                            if (item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] is FieldLookupValue[])
                            {
                                FieldLookupValue[] lookupFields = item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] as FieldLookupValue[];
                                List <string>      reletedto    = new List <string>();
                                foreach (FieldLookupValue lookupField in lookupFields)
                                {
                                    reletedto.Add(lookupField.LookupValue);
                                }
                                property.SetValue(listItem, reletedto);
                            }
                            else
                            {
                                FieldLookupValue lookupField = item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation] as FieldLookupValue;
                                if (lookupField != null)
                                {
                                    property.SetValue(listItem, lookupField.LookupValue);
                                }
                            }
                        }
                        else
                        {
                            property.SetValue(listItem, item[property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation]);
                        }
                    }
                }
                masterItems.Add(listItem);
            }
            PropertyInfo prop = objMaster.GetType().GetProperty("Items");

            prop.SetValue(objMaster, masterItems, null);
            return(objMaster);
        }
Example #16
0
        /// <summary>
        /// Esclates the request.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="web">The web.</param>
        /// <param name="item">The item.</param>
        /// <param name="mainListName">Name of the main list.</param>
        /// <param name="approverListName">Name of the approver list.</param>
        /// <returns>to users</returns>
        public static DataTable EsclateRequest(ClientContext context, Web web, ListItem item, string mainListName, string approverListName, DataTable tblEscalation, ref string toUser, int actionStatus)
        {
            try
            {
                DataRow dr      = tblEscalation.NewRow();
                string  userIDs = BELDataAccessLayer.GetEmailsFromPersonField(context, web, item["Approver"] as FieldUserValue[]);

                if (Convert.ToInt32(actionStatus) == 1)   //For Escalation Only
                {
                    string to = string.Empty;
                    foreach (string id in userIDs.Split(','))
                    {
                        UserDetails userDetail = BELDataAccessLayer.Instance.GetUserInformation(context, web, id);
                        if (userDetail != null)
                        {
                            to += "," + GetManagerEmail(context, web, userDetail.ReportingManager);
                            dr["UserFullName"] += userDetail.FullName + ", ";
                            dr["UserEmail"]    += userDetail.UserEmail + ", ";
                            dr["CCEmail"]      += userDetail.UserEmail + ",";
                        }
                    }
                    dr["ToEmail"]      = to.Trim(',');
                    dr["UserFullName"] = dr["UserFullName"].ToString().Trim(',');
                }
                else if (Convert.ToInt32(actionStatus) == 2) //For Reminder Only
                {
                    dr["UserEmail"]   = dr["ToEmail"] = BELDataAccessLayer.GetEmailUsingUserID(context, web, userIDs);
                    dr["PendingWith"] = dr["UserFullName"] = BELDataAccessLayer.GetNameUsingUserID(context, web, userIDs);
                }
                EmailHelper eHelper = new EmailHelper();/// Check if we can remove this.
                //List<ListItemDetail> listDetails = new List<ListItemDetail>();
                int      reqId    = (item["RequestID"] as FieldLookupValue).LookupId;
                List     mainList = web.Lists.GetByTitle(mainListName);
                ListItem mainItem = mainList.GetItemById(reqId);
                context.Load(mainItem);
                context.Load(mainList, m => m.DefaultDisplayFormUrl);
                context.ExecuteQuery();


                // dr["CCEmail"] = toUser;
                dr["EscOrReminder"]   = actionStatus;
                dr["ApplicationName"] = Convert.ToString(item["ApplicationName"]);
                dr["FormName"]        = Convert.ToString(item["FormName"]);
                // dr["ReferenceNo"] = (mainItem["DCRNo"] != null ? Convert.ToString(mainItem["DCRNo"]) : string.Empty);
                dr["RequestDate"] = (mainItem["RequestDate"] != null ? Convert.ToDateTime(mainItem["RequestDate"]).ToString("dd-MM-yyyy") : string.Empty);
                dr["AssignDate"]  = (item["AssignDate"] != null ? Convert.ToDateTime(item["AssignDate"]).ToLocalTime().ToString("dd-MM-yyyy") : string.Empty);
                //dr["BusinessUnit"] = (mainItem["BusinessUnit"] != null ? Convert.ToString(mainItem["BusinessUnit"]) : string.Empty);
                // dr["ProductName"] = (mainItem["ProductName"] != null ? Convert.ToString(mainItem["ProductName"]) : string.Empty);
                string link           = string.Empty;
                string referenceNo    = string.Empty;
                string emailSignature = string.Empty;
                link           = "#URL" + mainList.DefaultDisplayFormUrl + "?ID=" + mainItem["ID"];
                dr["ListName"] = mainListName;
                dr["ID"]       = mainItem.Id;
                if (mainListName == "DCR")
                {
                    referenceNo    = (mainItem["DCRNo"] != null ? Convert.ToString(mainItem["DCRNo"]) : string.Empty);
                    emailSignature = "DCRDCN Team";
                }
                else if (mainListName == "DCN")
                {
                    referenceNo    = (mainItem["DCNNo"] != null ? Convert.ToString(mainItem["DCNNo"]) : string.Empty);
                    emailSignature = "DCRDCN Team";
                }
                else if (mainListName == "NPD")
                {
                    referenceNo    = (mainItem["ProjectNo"] != null ? Convert.ToString(mainItem["ProjectNo"]) : string.Empty);
                    emailSignature = "NPD Team";
                }
                else if (mainListName == "Feedbacks")
                {
                    referenceNo    = (mainItem["FeedbackNo"] != null ? Convert.ToString(mainItem["FeedbackNo"]) : string.Empty);
                    emailSignature = "CC Department";
                }
                else if (mainListName == "ExistingArtwork")
                {
                    referenceNo    = (mainItem["ReferenceNo"] != null ? Convert.ToString(mainItem["ReferenceNo"]) : string.Empty);
                    emailSignature = "Artwork Team";
                }
                else if (mainListName == "NewArtwork")
                {
                    referenceNo    = (mainItem["ReferenceNo"] != null ? Convert.ToString(mainItem["ReferenceNo"]) : string.Empty);
                    emailSignature = "Artwork Team";
                }
                else if (mainListName == "ItemCodePreProcess")
                {
                    referenceNo    = (mainItem["Title"] != null ? Convert.ToString(mainItem["Title"]) : string.Empty);
                    emailSignature = "Item Code Document Management S​​ystem (SharePoint​)​​";
                }
                dr["Link"]           = link;
                dr["ReferenceNo"]    = referenceNo;
                dr["EmailSignature"] = emailSignature;
                dr["ActionStatus"]   = actionStatus;
                dr["DueDate"]        = (item["DueDate"] != null ? Convert.ToDateTime(item["DueDate"]).ToLocalTime().ToString("dd-MM-yyyy") : string.Empty);

                if (item["DueDate"] != null)
                {
                    dr["PendingSince"] = GetPendingDays(Convert.ToDateTime(item["DueDate"]));
                }
                else
                {
                    dr["PendingSince"] = "0";
                }
                string workflowstatus = Convert.ToString(mainItem["WorkflowStatus"]);
                if (!workflowstatus.Equals("Draft"))
                {
                    tblEscalation.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error Request Escalation: " + ex.Message);
                Console.Write(ex.StackTrace + "==>" + ex.Message);
                Logger.Error("Error Request Escalation: " + ex.Message);
            }
            return(tblEscalation);
        }
Example #17
0
 private ITrans SetTranProperties(ClientContext context, Web web, ListItem listItem, ITrans tranItem, PropertyInfo[] properties, bool getSubItems = true)
 {
     foreach (PropertyInfo property in properties)
     {
         bool   isListColumn  = property.GetCustomAttribute <IsListColumnAttribute>() == null || property.GetCustomAttribute <IsListColumnAttribute>().IsListColumn;
         bool   isTask        = property.GetCustomAttribute <IsTaskAttribute>() != null && property.GetCustomAttribute <IsTaskAttribute>().IsTaskField;
         bool   isTran        = property.GetCustomAttribute <IsTranAttribute>() != null && property.GetCustomAttribute <IsTranAttribute>().IsTranField;
         string listCoumnName = property.GetCustomAttribute <FieldColumnNameAttribute>() != null && !string.IsNullOrEmpty(property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation) ? property.GetCustomAttribute <FieldColumnNameAttribute>().FieldsInformation : property.Name;
         bool   isFile        = property.GetCustomAttribute <IsFileAttribute>() != null && property.GetCustomAttribute <IsFileAttribute>().IsFile;
         if (isListColumn)
         {
             if (property.GetCustomAttribute <FieldColumnNameAttribute>() != null && property.GetCustomAttribute <FieldColumnNameAttribute>().IsLookup)
             {
                 FieldLookupValue lookupField = listItem[listCoumnName] as FieldLookupValue;
                 property.SetValue(tranItem, lookupField.LookupId);
             }
             else if (property.GetCustomAttribute <IsPersonAttribute>() != null && property.GetCustomAttribute <IsPersonAttribute>().IsPerson)
             {
                 FieldUserValue[] users = null;
                 if (listItem[listCoumnName] != null)
                 {
                     if (property.GetCustomAttribute <IsPersonAttribute>().IsMultiple)
                     {
                         users = listItem[listCoumnName] as FieldUserValue[];
                     }
                     else
                     {
                         users    = new FieldUserValue[1];
                         users[0] = listItem[listCoumnName] as FieldUserValue;
                     }
                 }
                 if (users != null && !property.GetCustomAttribute <IsPersonAttribute>().ReturnName)
                 {
                     string personEmails = BELDataAccessLayer.GetEmailsFromPersonField(context, web, users);
                     property.SetValue(tranItem, personEmails);
                 }
                 else if (users != null && property.GetCustomAttribute <IsPersonAttribute>().ReturnName)
                 {
                     string personEmails = BELDataAccessLayer.GetNameFromPersonField(context, web, users);
                     property.SetValue(tranItem, personEmails);
                 }
             }
             else if (isFile)
             {
                 if (Convert.ToString(listItem["Attachments"]) == "True")
                 {
                     context.Load(listItem.AttachmentFiles);
                     context.ExecuteQuery();
                     AttachmentCollection attachments        = listItem.AttachmentFiles;
                     List <FileDetails>   objAttachmentFiles = this.GetAttachments(attachments);
                     property.SetValue(tranItem, objAttachmentFiles);
                 }
             }
             else
             {
                 object value     = listItem[listCoumnName];
                 Type   t         = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
                 object safeValue = (value == null) ? null : Convert.ChangeType(value, t);
                 property.SetValue(tranItem, safeValue);
             }
         }
         else if (isTran)
         {
             if (getSubItems)
             {
                 string listName = property.GetCustomAttribute <IsTranAttribute>().TranListName;
                 Type   tSubTran = property.GetCustomAttribute <IsTranAttribute>().TranType;
                 if (!string.IsNullOrEmpty(listName))
                 {
                     List <ITrans> subTrans = this.GetTransactionListData(context, web, tSubTran, listName, Convert.ToInt32(listItem["ID"]));
                     property.SetValue(tranItem, subTrans);
                 }
             }
         }
         ////else if (isTask)
         ////{
         ////    string listName = property.GetCustomAttribute<IsTaskAttribute>().TaskListName;
         ////    Type tSubTask = property.GetCustomAttribute<IsTaskAttribute>().TaskType;
         ////    if (!string.IsNullOrEmpty(listName))
         ////    {
         ////        List<ITask> subTasks = this.GetTaskListData(context, web, tSubTask, listName, Convert.ToInt32(listItem["ID"]));
         ////        property.SetValue(taskItem, subTasks);
         ////    }
         ////}
     }
     return(tranItem);
 }