예제 #1
0
    private static string BuildTitle(Task emailTask, IMTDService service)
    {
        string retVal = "";

        retVal = emailTask.Task_CID.GetExternalText() + "; ";

        Base.Attribute projectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROJECT"));
        if (projectAttr != null)
        {
            BaseExtendable project = new BaseExtendable(CodeTranslator.Find("ENTITY_TYPE", "PROJECT").Code_IID);
            project.Entity_IID = (int)projectAttr.Value;
            project            = (BaseExtendable)service.Load(project);
            service.LoadAttributes(project);

            Base.Attribute contactAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "CONTACT"));
            if (contactAttr != null)
            {
                Contact targetContact = new Contact((int)contactAttr.Value);
                targetContact = (Contact)service.Load(targetContact);
                retVal       += targetContact.Customer_Name + "; ";

                /*
                 * CustomerSite targetSite = new CustomerSite(targetContact.Site_IID);
                 * targetSite = (CustomerSite)service.Load(targetSite);
                 * Customer targetCustomer = new Customer(targetSite.Customer_IID);
                 * targetCustomer = (Customer)service.Load(targetCustomer);
                 * retVal += targetCustomer.Name + "; ";
                 */
            }

            retVal += project.Description + "; ";

            Base.Attribute projectNumAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"));
            if (projectNumAttr != null)
            {
                retVal += "P#:" + (string)projectNumAttr.Value;
            }
            else
            {
                retVal += "Q#:" + project.OID;
            }
        }
        else
        {
            Base.Attribute prospectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROSPECT"));
            if (prospectAttr != null)
            {
                int          prospectIID = (int)prospectAttr.Value;
                Prospect     propect     = service.LoadProspect(prospectIID);
                CustomerSite site        = service.LoadCustomerSite(propect.Site_IID);
                Customer     cust        = service.LoadCustomer(site.Customer_IID);
                retVal += " " + propect.First_Name + " " + propect.Last_Name + " (" + cust.Name + ")";
            }
        }

        return(retVal);
    }
        public BaseExtendable createMTDQuote(int contact_iid, string projDesc, TMAMessage msg, IMTDService svc, UserSession us, Guid mtdGUID, int srcLangCID, int[] targetLangCIDs)
        {
            BaseExtendable newQuote = new BaseExtendable(Code.Find(AppCodes.PROJECT_TARGET_TYPE).CID);

            if (msg.name != null)
            {
                newQuote.Description = msg.name;
            }
            else
            {
                newQuote.Description = projDesc;
            }
            newQuote.OID = svc.NextSequenceNumber(true);
            svc.Store(newQuote);
            ///// Add Attributes
            /////////////////////////////////////////////////////////////////////////////////////

            //           int contact_iid = Convert.ToInt32(ConfigurationSettings.AppSettings["CONTACT_IID"]);

            Contact      contact        = svc.LoadContact(contact_iid);
            CustomerSite site           = svc.LoadCustomerSite(contact.Site_IID);
            int          salesPersonIID = site.Sales_Employee_IID;

            if (salesPersonIID == -1)
            {
                salesPersonIID = us.Current_User.Employee.Employee_IID; // vilma
            }

            Base.Attribute salesAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SALESPERSON"), salesPersonIID);
            salesAttr.SetParent(newQuote.Attributes);

            Base.Attribute contactAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "CONTACT"), contact_iid);
            contactAttr.SetParent(newQuote.Attributes);
            // msg.status ='approved"
            Base.Attribute statusAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "STATUS"), Code.Find(10033));
            statusAttr.SetParent(newQuote.Attributes);
            // Quoted
            int perCt = 10;

            Base.Attribute pmPercentAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PM_PERCENT"), perCt);
            pmPercentAttr.SetParent(newQuote.Attributes);

            decimal internalRate = 35;

            Base.Attribute internalRateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BASE_INTERNAL_RATE"), internalRate);
            internalRateAttr.SetParent(newQuote.Attributes);

            Base.Attribute sourceAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SOURCE_LANG"), Code.Find(srcLangCID));
            sourceAttr.SetParent(newQuote.Attributes);
            int targetCID;
            int numLangs = targetLangCIDs.Length;

            for (int i = 0; i < numLangs; i++)
            {
                targetCID = targetLangCIDs[i];
                if (targetCID > 0)
                {
                    Base.Attribute targetLang = newQuote.Attributes.Add(CodeTranslator.Find("CTYPE", "LOC"), Code.Find(targetCID), 0);
                    targetLang.SetParent(newQuote.Attributes);
                }
            }

            /*
             * Base.Attribute budgetAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BUDGET"), this.BudgetCheckBox.Checked);
             * budgetAttr.SetParent(newQuote.Attributes);
             * Base.Attribute rushAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "RUSH_JOB"), this.RushCheckBox.Checked);
             * rushAttr.SetParent(newQuote.Attributes);
             * Base.Attribute reverseAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "LANGUAGES_REVERSED"), this.ReverseCheckBox.Checked);
             * reverseAttr.SetParent(newQuote.Attributes);
             * Base.Attribute cleanAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PRE_TRANS_CLEANING"), this.CleanCheckBox.Checked);
             * cleanAttr.SetParent(newQuote.Attributes);
             */

            //DateTime dTime = new DateTime(2012, 09, 01, 12, 00, 00);
            //String dTime;
            //dTime = defDTime.ToString("yyyy-MM-dd HH:mm tt");

            Base.Attribute dateQuoteStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_START_DT"), DateTime.Now);
            dateQuoteStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAssessStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_START_DT"), DateTime.Now);
            dateAssessStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateQuoteDueeAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_DUE_DT"), DateTime.Now.AddDays(1));
            dateQuoteDueeAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAsessDueAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), DateTime.Now.AddDays(1));
            dateAsessDueAttr.SetParent(newQuote.Attributes);

            /*
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             */

            svc.Store(newQuote);


            msg.quoteOID = newQuote.OID;
            // Update Quote if first
            ProspectCollection prospects = svc.LoadProspectCollection(Convert.ToInt32("5157"));

            if (prospects.Count > 0)
            {
                Prospect updateProspect = (Prospect)prospects[0];
                if (updateProspect.Quote_IID == -1)
                {
                    updateProspect.Quote_IID = newQuote.Entity_IID;
                    svc.Store(updateProspect);
                }
            }

            BaseExtendable m_project = newQuote;

            return(m_project);
        }
예제 #3
0
    private static string BuildHeader(Task emailTask, IMTDService service)
    {
        string retVal = "<strong>Task Information</strong><br>";

        Base.Attribute projectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROJECT"));
        if (projectAttr != null)
        {
            BaseExtendable project = new BaseExtendable(CodeTranslator.Find("ENTITY_TYPE", "PROJECT").Code_IID);
            project.Entity_IID = (int)projectAttr.Value;
            project            = (BaseExtendable)service.Load(project);
            service.LoadAttributes(project);

            retVal += "Quote Number: " + project.OID + "<br>";

            Base.Attribute projectNumAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"));
            if (projectNumAttr != null)
            {
                retVal += "Project Number: " + (string)projectNumAttr.Value + "<br>";
            }

            retVal += "Description: " + project.Description + "<br>";

            Base.Attribute contactAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "CONTACT"));
            if (contactAttr != null)
            {
                Contact targetContact = new Contact((int)contactAttr.Value);
                targetContact = (Contact)service.Load(targetContact);
                retVal       += "Company: " + targetContact.Customer_Name + "<br>";

                /*
                 * CustomerSite targetSite = new CustomerSite(targetContact.Site_IID);
                 * targetSite = (CustomerSite)service.Load(targetSite);
                 * Customer targetCustomer = new Customer(targetSite.Customer_IID);
                 * targetCustomer = (Customer)service.Load(targetCustomer);
                 * retVal += "Company: " + targetCustomer.Name + "<br>";
                 */
            }
        }

        retVal += "Task Status: " + emailTask.Task_Status_CID.GetExternalText() + "<br>";


        UserRole createRole = service.LoadUserRole(emailTask.Created_User_Role_IID);

        retVal += "Task Created By: " + createRole.User.DisplayName + "<br>";

        if (emailTask.Pending_User_Role_IID != -1)
        {
            UserRole pendingRole = service.LoadUserRole(emailTask.Pending_User_Role_IID);
            retVal += "Task Pending Acceptance: " + pendingRole.User.DisplayName + "<br>";
        }
        if (emailTask.Current_User_Role_IID != -1)
        {
            UserRole currentRole = service.LoadUserRole(emailTask.Current_User_Role_IID);
            retVal += "Task Owned By: " + currentRole.User.DisplayName + "<br>";
        }

        retVal += "<hr><br>";

        return(retVal);
    }
        public BaseExtendable createMTDProject(int contact_iid, string projDesc, TMAMessage msg, IMTDService svc, UserSession us, Guid mtdGUID, int srcLangCID, int[] targetLangCIDs, bool monthlyFlag)
        {
            BaseExtendable newQuote = new BaseExtendable(Code.Find(AppCodes.PROJECT_TARGET_TYPE).CID);

            if (msg.name != null)
            {
                newQuote.Description = msg.name;
            }
            else
            {
                newQuote.Description = projDesc;
            }
            newQuote.OID = svc.NextSequenceNumber(true);
            svc.Store(newQuote);
            ///// Add Attributes
            /////////////////////////////////////////////////////////////////////////////////////

            //           int contact_iid = Convert.ToInt32(ConfigurationSettings.AppSettings["CONTACT_IID"]);

            Contact      contact        = svc.LoadContact(contact_iid);
            CustomerSite site           = svc.LoadCustomerSite(contact.Site_IID);
            int          salesPersonIID = site.Sales_Employee_IID;

            if (salesPersonIID == -1)
            {
                salesPersonIID = us.Current_User.Employee.Employee_IID; // vilma
            }

            Base.Attribute salesAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SALESPERSON"), salesPersonIID);
            salesAttr.SetParent(newQuote.Attributes);

            Base.Attribute contactAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "CONTACT"), contact_iid);
            contactAttr.SetParent(newQuote.Attributes);
            // msg.status ='approved"
            Base.Attribute statusAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "STATUS"), Code.Find(10033));
            statusAttr.SetParent(newQuote.Attributes);
            // Quoted
            decimal perCt = 10;

            Base.Attribute pmPercentAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PM_PERCENT"), perCt);
            pmPercentAttr.SetParent(newQuote.Attributes);

            decimal internalRate = 35;

            Base.Attribute internalRateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BASE_INTERNAL_RATE"), internalRate);
            internalRateAttr.SetParent(newQuote.Attributes);                                            // use default from MTD web config

            Base.Attribute sourceAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SOURCE_LANG"), Code.Find(srcLangCID));
            sourceAttr.SetParent(newQuote.Attributes);
            int targetCID;
            int numLangs = targetLangCIDs.Length;

            for (int i = 0; i < numLangs; i++)
            {
                targetCID = targetLangCIDs[i];
                if (targetCID > 0)
                {
                    Base.Attribute targetLang = newQuote.Attributes.Add(CodeTranslator.Find("CTYPE", "LOC"), Code.Find(targetCID), 0);
                    targetLang.SetParent(newQuote.Attributes);
                }
            }

            /*
             * Base.Attribute budgetAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BUDGET"), this.BudgetCheckBox.Checked);
             * budgetAttr.SetParent(newQuote.Attributes);
             * Base.Attribute rushAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "RUSH_JOB"), this.RushCheckBox.Checked);
             * rushAttr.SetParent(newQuote.Attributes);
             * Base.Attribute reverseAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "LANGUAGES_REVERSED"), this.ReverseCheckBox.Checked);
             * reverseAttr.SetParent(newQuote.Attributes);
             * Base.Attribute cleanAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PRE_TRANS_CLEANING"), this.CleanCheckBox.Checked);
             * cleanAttr.SetParent(newQuote.Attributes);
             */

            //DateTime dTime = new DateTime(2012, 09, 01, 12, 00, 00);
            //String dTime;
            //dTime = defDTime.ToString("yyyy-MM-dd HH:mm tt");

            Base.Attribute dateQuoteStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_START_DT"), DateTime.Now);
            dateQuoteStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAssessStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_START_DT"), DateTime.Now);
            dateAssessStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateQuoteDueeAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_DUE_DT"), DateTime.Now.AddDays(1));
            dateQuoteDueeAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAsessDueAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), DateTime.Now.AddDays(1));
            dateAsessDueAttr.SetParent(newQuote.Attributes);

            /*
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             *
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             */

            svc.Store(newQuote);


            msg.quoteOID = newQuote.OID;



            //convert Quote to Project
            string projectNum = svc.NextSequenceNumber(false);

            BaseExtendable m_project = newQuote;

            Code statusCode = Code.Find("PROJECT_STATUS", "LINGUISTIC");

            statusAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "STATUS"));
            if (statusAttr == null)
            {
                statusAttr = m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "STATUS"), statusCode);
                statusAttr.SetParent(m_project.Attributes);
            }
            else
            {
                statusAttr.Value = statusCode;
            }
            Base.Attribute projStartDate = m_project.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_START_DT"), DateTime.Now);
            projStartDate.SetParent(m_project.Attributes);

            Base.Attribute prodStartDate = m_project.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_START_DT"), DateTime.Now);
            prodStartDate.SetParent(m_project.Attributes);


            Base.Attribute monthlyAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "MONTHLY"));
            if (monthlyAttr == null && monthlyFlag == true)
            {
                monthlyAttr = m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "MONTHLY"), monthlyFlag);
                monthlyAttr.SetParent(m_project.Attributes);
            }

            m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"), projectNum);

            bool itar = false;

            Base.Attribute itarAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "ITAR"));
            if (itarAttr != null)
            {
                itar = ((bool)itarAttr.Value);
                itarAttr.SetParent(m_project.Attributes);
            }

            svc.Store(m_project);
            return(m_project);
        }