public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string user_name = context.Request.Params.Get("user_name");

            if (isNull(user_name))
            {
                return(new PagedData("Heartbeat.ashx expects a user_name"));
            }

            string project_id = context.Request.Params.Get("project_id");

            if (isNull(project_id))
            {
                return(new PagedData("Heartbeat.ashx expects a project_id"));
            }

            ProjectInformation pi = db.ProjectInformations.Single(a => a.project_id.Equals(project_id));

            pi.last_time = DateTime.Now.ToString();  //update the project with the current time

            User record = db.Users.Single(a => a.user_name.Equals(user_name));

            record.last_time = DateTime.Now.ToString();  //update record with the current time
            db.SubmitChanges();

            return(new PagedData("Done"));
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <ProjectInformation> q = db.ProjectInformations;

            string filter = context.Request.Params.Get("project_id");

            if (!isNull(filter))
            {
                string user_name = context.Request.Params.Get("user_name");
                if (!isNull(user_name))
                {
                    ProjectInformation pi = db.ProjectInformations.Single(a => a.project_id.Equals(int.Parse(filter)));

                    if (((bool)pi.locked) && pi.user_name.Equals(user_name, StringComparison.OrdinalIgnoreCase))
                    {
                        //unlock it
                        pi.locked    = false;
                        pi.user_name = null;
                        db.SubmitChanges();

                        return(new PagedData("Project successfully released"));
                    }

                    return(new PagedData("Project is currently unlocked.  Nothing to release"));
                }

                return(new PagedData("ReleaseProjectLock.ashx requires a user_name"));
            }

            return(new PagedData("ReleaseProjectLock.ashx requires a project_id"));
        }
        /**
         * Arguments:
         *      - ProjectInformation object
         *      - locationToSave string. For example: 'C:\\' or "\\nor2k3ops1\e_drive\Project Management\Projects\CitiGroup\SEARS\CTG-3000s\CTG-3171 Project Nuance Phase I - NLU". Filename will be appended
         */
        public string saveReport(ProjectInformation pi, string locationToSave)
        {
            /* Generating Report String */
            ReportGenerator generator    = new ReportGenerator();
            string          reportString = "";

            reportString = reportString + generator.generateStart();
            reportString = reportString + generator.generateProjectId(pi.CTGNumber, pi.ProjectName);
            reportString = reportString + generator.generatePMAssigned(pi.PMName);
            reportString = reportString + generator.generateProjectDescription(pi.Description);
            reportString = reportString + generator.generateRecordingSection(pi.getLanguagePrompts(), pi.getNotes("Prompts"));
            reportString = reportString + generator.generateAssumptions(pi.getAssumptions(false), false, pi.getNotes("Assumptions (Project Specific)"));
            reportString = reportString + generator.generateAssumptions(pi.getAssumptions(true), true, pi.getNotes("Assumptions (Standard)"));
            reportString = reportString + generator.generateDeliverables(pi.getDeliverables(), pi.getNotes("Customer Deliverables"));
            reportString = reportString + generator.generateHoursX("Dev Billable", pi.getDEVHours_billable(), pi.getNotes("DEV Hours (billable)"));
            reportString = reportString + generator.generateHoursX("Dev Unbillable", pi.getDEVHours_unbillable(), pi.getNotes("DEV Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("PM Hours", pi.getPMHours(), pi.getNotes("PM Hours"));
            reportString = reportString + generator.generateHoursX("TC Billable", pi.getTCHours_billable(), pi.getNotes("TC Hours (billable)"));
            reportString = reportString + generator.generateHoursX("TC Unbillable", pi.getTCHours_unbillable(), pi.getNotes("TC Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("TLS", pi.getTLSHours_billable(), pi.getNotes("TLS Hours"));
            //reportString = reportString + generator.generateHoursX("TLS Unbillable", pi.getTLSHours_unbillable(), pi.getNotes("TLS Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("QA Hours", pi.getQAHours(), pi.getNotes("QA Hours"));
            reportString = reportString + generator.generateHoursX("SYS Billable", pi.getSYSHours_billable(), pi.getNotes("SYS Hours (billable)"));
            reportString = reportString + generator.generateHoursX("SYS Unbillable", pi.getSYSHours_unbillable(), pi.getNotes("SYS Hours (unbillable)"));
            reportString = reportString + generator.generateHardware(pi.getHardware(), pi.getNotes("Hardware"));
            reportString = reportString + generator.generateDevStartDate(pi.getDevStarts(), pi.getNotes("Dev Start Date"));
            reportString = reportString + generator.generateDevCompleteDate(pi.getDevCompletes(), pi.getNotes("Dev Complete Date"));
            reportString = reportString + generator.generateQuotedDeliveryDate(pi.getQuotedDeliveryDates(), pi.getNotes("Quoted Delivery"));
            reportString = reportString + generator.generateEnd();


            /*  Saving Report */
            DateTime date           = DateTime.Now;
            string   timeStamp      = "" + date.Year + date.Month + date.Day + "_" + date.Hour + date.Minute + date.Second;
            string   reportFileName = pi.CTGNumber + " IFQ" + timeStamp + ".html";

            if (!(locationToSave.EndsWith("\\") || locationToSave.EndsWith("/")))
            {
                locationToSave = locationToSave + "\\";
            }

            string     filePath = locationToSave + reportFileName;
            FileStream fStream  = new FileStream(
                filePath,
                FileMode.Create,
                FileAccess.Write,
                FileShare.Read);
            StreamWriter sw = new StreamWriter(fStream);

            sw.Write(reportString);
            sw.Close();      // Close the Stream
            fStream.Close(); // Close the File
            return(reportFileName);
        }
        /**
         * Arguments:
         *      - ProjectInformation object
         *      - locationToSave string. For example: 'C:\\' or "\\nor2k3ops1\e_drive\Project Management\Projects\CitiGroup\SEARS\CTG-3000s\CTG-3171 Project Nuance Phase I - NLU". Filename will be appended
         */
        public string saveReport(ProjectInformation pi, string locationToSave)
        {

            /* Generating Report String */
            ReportGenerator generator = new ReportGenerator();
            string reportString = "";
            reportString = reportString + generator.generateStart();
            reportString = reportString + generator.generateProjectId(pi.CTGNumber, pi.ProjectName);
            reportString = reportString + generator.generatePMAssigned(pi.PMName);
            reportString = reportString + generator.generateProjectDescription(pi.Description);
            reportString = reportString + generator.generateRecordingSection(pi.getLanguagePrompts(), pi.getNotes("Prompts"));
            reportString = reportString + generator.generateAssumptions(pi.getAssumptions(false), false, pi.getNotes("Assumptions (Project Specific)"));
            reportString = reportString + generator.generateAssumptions(pi.getAssumptions(true), true, pi.getNotes("Assumptions (Standard)"));
            reportString = reportString + generator.generateDeliverables(pi.getDeliverables(), pi.getNotes("Customer Deliverables"));
            reportString = reportString + generator.generateHoursX("Dev Billable", pi.getDEVHours_billable(), pi.getNotes("DEV Hours (billable)"));
            reportString = reportString + generator.generateHoursX("Dev Unbillable", pi.getDEVHours_unbillable(), pi.getNotes("DEV Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("PM Hours", pi.getPMHours(), pi.getNotes("PM Hours"));
            reportString = reportString + generator.generateHoursX("TC Billable", pi.getTCHours_billable(), pi.getNotes("TC Hours (billable)"));
            reportString = reportString + generator.generateHoursX("TC Unbillable", pi.getTCHours_unbillable(), pi.getNotes("TC Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("TLS", pi.getTLSHours_billable(), pi.getNotes("TLS Hours"));
            //reportString = reportString + generator.generateHoursX("TLS Unbillable", pi.getTLSHours_unbillable(), pi.getNotes("TLS Hours (unbillable)"));
            reportString = reportString + generator.generateHoursX("QA Hours", pi.getQAHours(), pi.getNotes("QA Hours"));
            reportString = reportString + generator.generateHoursX("SYS Billable", pi.getSYSHours_billable(), pi.getNotes("SYS Hours (billable)"));
            reportString = reportString + generator.generateHoursX("SYS Unbillable", pi.getSYSHours_unbillable(), pi.getNotes("SYS Hours (unbillable)"));
            reportString = reportString + generator.generateHardware(pi.getHardware(), pi.getNotes("Hardware"));
            reportString = reportString + generator.generateDevStartDate(pi.getDevStarts(), pi.getNotes("Dev Start Date"));
            reportString = reportString + generator.generateDevCompleteDate(pi.getDevCompletes(), pi.getNotes("Dev Complete Date"));
            reportString = reportString + generator.generateQuotedDeliveryDate(pi.getQuotedDeliveryDates(), pi.getNotes("Quoted Delivery"));
            reportString = reportString + generator.generateEnd();


            /*  Saving Report */
            DateTime date = DateTime.Now;
            string timeStamp = "" + date.Year + date.Month + date.Day + "_" + date.Hour + date.Minute + date.Second;
            string reportFileName = pi.CTGNumber + " IFQ" + timeStamp + ".html";
            if (!(locationToSave.EndsWith("\\") || locationToSave.EndsWith("/")))
            {
                locationToSave = locationToSave + "\\";
            }

            string filePath = locationToSave + reportFileName;
            FileStream fStream = new FileStream(
                filePath,
                FileMode.Create,
                FileAccess.Write,
                FileShare.Read);
            StreamWriter sw = new StreamWriter(fStream);
            sw.Write(reportString);
            sw.Close();     // Close the Stream
            fStream.Close();     // Close the File
            return reportFileName;
        }
 partial void DeleteProjectInformation(ProjectInformation instance);
 partial void UpdateProjectInformation(ProjectInformation instance);
 partial void InsertProjectInformation(ProjectInformation instance);
Esempio n. 8
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string user_name = context.Request.Params.Get("user_name");

            if (isNull(user_name))
            {
                return(new PagedData("CreateNewProject.ashx expects a user_name"));
            }

            ProjectInformation newProject = new ProjectInformation();

            newProject.locked    = true;      //start the project off as locked by the user who created it
            newProject.user_name = user_name; //
            db.ProjectInformations.InsertOnSubmit(newProject);
            db.SubmitChanges();               //create the new project so we can have a new project_id with which to create new records in other tables


            //create a new record in dependent tables
            MISNew newMISNew = new MISNew();

            newMISNew.project_id = newProject.project_id;
            db.MISNews.InsertOnSubmit(newMISNew);
            db.SubmitChanges();

            MISNewDelivery newMISDelivery = new MISNewDelivery();

            newMISDelivery.mis_new_id = newMISNew.mis_new_id;
            db.MISNewDeliveries.InsertOnSubmit(newMISDelivery);

            MISUpdate newMISUpdate = new MISUpdate();

            newMISUpdate.project_id  = newProject.project_id;
            newMISUpdate.description = "";
            db.MISUpdates.InsertOnSubmit(newMISUpdate);
            db.SubmitChanges();

            MISUpdateDeliveryChange newMISUpdateDeliveryChange = new MISUpdateDeliveryChange();

            newMISUpdateDeliveryChange.mis_update_id = newMISUpdate.mis_update_id;
            db.MISUpdateDeliveryChanges.InsertOnSubmit(newMISUpdateDeliveryChange);

            ProdInstallationBuffet prodBuffet = new ProdInstallationBuffet();

            prodBuffet.project_id = newProject.project_id;
            db.ProdInstallationBuffets.InsertOnSubmit(prodBuffet);

            PromptWorksheet promptWorksheet = new PromptWorksheet();

            promptWorksheet.project_id       = newProject.project_id;
            promptWorksheet.prompt_worksheet = "";
            promptWorksheet.prompt_summary   = "";
            db.PromptWorksheets.InsertOnSubmit(promptWorksheet);

            SWDSchedule swdSchedule = new SWDSchedule();

            swdSchedule.project_id = newProject.project_id;
            db.SWDSchedules.InsertOnSubmit(swdSchedule);

            TrafficRequirement trafficRequirement = new TrafficRequirement();

            trafficRequirement.project_id = newProject.project_id;
            db.TrafficRequirements.InsertOnSubmit(trafficRequirement);

            UatProdInstall uatProdInstall = new UatProdInstall();

            uatProdInstall.project_id = newProject.project_id;
            db.UatProdInstalls.InsertOnSubmit(uatProdInstall);

            db.SubmitChanges();

            //insert a history note that the project was created
            ProjectHistory historyNote = new ProjectHistory();

            historyNote.project_id  = newProject.project_id;
            historyNote.user_name   = user_name;
            historyNote.description = "Project created";
            historyNote.date        = DateTime.Today.ToString("yyyy-MM-dd");
            db.ProjectHistories.InsertOnSubmit(historyNote);

            db.SubmitChanges();

            return(new PagedData(new { newProject.project_id }));
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {

            string user_name = context.Request.Params.Get("user_name");
            if (isNull(user_name))
            {
                return new PagedData("CreateNewProject.ashx expects a user_name");
            }

            ProjectInformation newProject = new ProjectInformation();
            newProject.locked = true;           //start the project off as locked by the user who created it
            newProject.user_name = user_name;   //
            db.ProjectInformations.InsertOnSubmit(newProject);
            db.SubmitChanges();  //create the new project so we can have a new project_id with which to create new records in other tables


            //create a new record in dependent tables
            MISNew newMISNew = new MISNew();
            newMISNew.project_id = newProject.project_id;
            db.MISNews.InsertOnSubmit(newMISNew);
            db.SubmitChanges();

            MISNewDelivery newMISDelivery = new MISNewDelivery();
            newMISDelivery.mis_new_id = newMISNew.mis_new_id;
            db.MISNewDeliveries.InsertOnSubmit(newMISDelivery);

            MISUpdate newMISUpdate = new MISUpdate();
            newMISUpdate.project_id = newProject.project_id;
            newMISUpdate.description = "";
            db.MISUpdates.InsertOnSubmit(newMISUpdate);
            db.SubmitChanges();

            MISUpdateDeliveryChange newMISUpdateDeliveryChange = new MISUpdateDeliveryChange();
            newMISUpdateDeliveryChange.mis_update_id = newMISUpdate.mis_update_id;
            db.MISUpdateDeliveryChanges.InsertOnSubmit(newMISUpdateDeliveryChange);

            ProdInstallationBuffet prodBuffet = new ProdInstallationBuffet();
            prodBuffet.project_id = newProject.project_id;
            db.ProdInstallationBuffets.InsertOnSubmit(prodBuffet);

            PromptWorksheet promptWorksheet = new PromptWorksheet();
            promptWorksheet.project_id = newProject.project_id;
            promptWorksheet.prompt_worksheet = "";
            promptWorksheet.prompt_summary = "";
            db.PromptWorksheets.InsertOnSubmit(promptWorksheet);

            SWDSchedule swdSchedule = new SWDSchedule();
            swdSchedule.project_id = newProject.project_id;
            db.SWDSchedules.InsertOnSubmit(swdSchedule);

            TrafficRequirement trafficRequirement = new TrafficRequirement();
            trafficRequirement.project_id = newProject.project_id;
            db.TrafficRequirements.InsertOnSubmit(trafficRequirement);

            UatProdInstall uatProdInstall = new UatProdInstall();
            uatProdInstall.project_id = newProject.project_id;
            db.UatProdInstalls.InsertOnSubmit(uatProdInstall);

            db.SubmitChanges();

            //insert a history note that the project was created
            ProjectHistory historyNote = new ProjectHistory();
            historyNote.project_id = newProject.project_id;
            historyNote.user_name = user_name;
            historyNote.description = "Project created";
            historyNote.date = DateTime.Today.ToString("yyyy-MM-dd");
            db.ProjectHistories.InsertOnSubmit(historyNote);

            db.SubmitChanges();

            return new PagedData(new { newProject.project_id });
        }
Esempio n. 10
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <ProjectInformation> q = db.ProjectInformations;

            string filter = context.Request.Params.Get("project_id");

            if (!isNull(filter))
            {
                string user_name = context.Request.Params.Get("user_name");
                if (!isNull(user_name))
                {
                    //ah -- make sure the user is in the DB
                    if (!(db.Users.Count(a => a.user_name.Equals(user_name)) > 0))
                    {
                        return(new PagedData("AcquireProjectLock.ashx requires a valid user. Please ask Cookbook Admin to add you as a user."));
                    }

                    ProjectInformation pi = db.ProjectInformations.Single(a => a.project_id.Equals(int.Parse(filter)));

                    if (!((bool)pi.locked)) //|| pi.user_name.Equals(user_name, StringComparison.OrdinalIgnoreCase))
                    {
                        //lock it
                        pi.locked    = true;
                        pi.user_name = user_name;
                        pi.last_time = DateTime.Now.ToString();

                        //also update the timestamp on the Users table
                        User record = db.Users.Single(a => a.user_name.Equals(user_name));
                        record.last_time = DateTime.Now.ToString();

                        db.SubmitChanges();

                        return(new PagedData("Project successfully acquired"));
                    }

                    //ah - if last_time is null, let the user in
                    if (pi.last_time == null)
                    {
                        pi.locked    = true;
                        pi.user_name = user_name;
                        pi.last_time = DateTime.Now.ToString();

                        //also update the timestamp on the Users table to reflect this acquisition
                        User record = db.Users.Single(a => a.user_name.Equals(user_name));
                        record.last_time = DateTime.Now.ToString();

                        db.SubmitChanges();

                        return(new PagedData("Project successfully acquired"));
                    }

                    //(smm) Check the last_time of the project.
                    //If the time span is greater than 65 seconds, then release the lock by giving it to the requester
                    if ((DateTime.Now - DateTime.Parse(pi.last_time)).TotalSeconds > 75)
                    {
                        pi.locked    = true;
                        pi.user_name = user_name;
                        pi.last_time = DateTime.Now.ToString();

                        //also update the timestamp on the Users table to reflect this acquisition
                        User record = db.Users.Single(a => a.user_name.Equals(user_name));
                        record.last_time = DateTime.Now.ToString();

                        db.SubmitChanges();

                        return(new PagedData("Project successfully acquired"));
                    }

                    return(new PagedData("Project is currently locked by " + pi.user_name));
                }

                return(new PagedData("AcquireProjectLock.ashx requires a user_name"));
            }

            return(new PagedData("AcquireProjectLock.ashx requires a project_id"));
        }
        public string parseString(String incString, CookDBDataContext db, string filter, string url)
        {
            //ToDo: probably should add error handling on EVERY replacement, in case the replacement string is not found we can add {xxxx not found}. this is already
            //done for the findContacts contacts
            ProjectInformation currentProj = db.ProjectInformations.Single(c => c.project_id.Equals(Convert.ToInt32(filter)));

            try
            {
                incString = incString.Replace("[ProjectNumber]", currentProj.project_number);
            }
            catch (Exception)
            {
                incString = incString.Replace("[ProjectNumber]", "ProjectNumber Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[ProjectName]", currentProj.project_name);
            }
            catch (Exception)
            {
                incString = incString.Replace("[ProjectName]", "ProjectName Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[RFQRecDate]", currentProj.rfq_loe_recv_date);
            }
            catch (Exception)
            {
                incString = incString.Replace("[RFQRecDate]", "RFQRecDate Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[RFQDueDate]", currentProj.quote_loe_due_date);
            }
            catch (Exception)
            {
                incString = incString.Replace("[RFQDueDate]", "RFQDueDate Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[RequestedUATDate]", currentProj.requested_uat_date);
            }
            catch (Exception)
            {
                incString = incString.Replace("[RequestedProdDate]", "RequestedProdDate Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[RequestedProdDate]", currentProj.requested_prod_date);
            }
            catch (Exception)
            {
                incString = incString.Replace("[RequestedProdDate]", "RequestedProdDate Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[SummaryBU]", currentProj.primary_business_unit);
            }
            catch (Exception)
            {
                incString = incString.Replace("[SummaryBU]", "SummaryBU Exception. Contact Cookbook Admin.");
            }
            try
            {
                incString = incString.Replace("[ProjectFolderLink]", "<a href='" + currentProj.project_folder + "'>" + currentProj.project_folder + "</a>");
            }
            catch (Exception)
            {
                incString = incString.Replace("[ProjectFolderLink]", "ProjectFolderLink Exception. Contact Cookbook Admin.");
            }
            try
            {
                if (url.Contains('?'))
                {
                    url = url.Substring(0, url.IndexOf('?'));
                }
                url       = url + "?p=" + currentProj.project_number;
                incString = incString.Replace("[CookbookLink]", "<a href=" + url + ">" + url + "</a>");
            }
            catch (Exception)
            {
                incString = incString.Replace("[CookbookLink]", "CookbookLink Exception. Contact Cookbook Admin.");
            }
            //prompts folder
            try
            {
                if (db.PromptWorksheets.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                {
                    var pf = db.PromptWorksheets.First(d => d.project_id.Equals(Convert.ToInt32(filter))).prompt_worksheet;
                    incString = incString.Replace("[PromptsFolderLink]", "<a href='" + pf + "'>" + pf + "</a>");
                }
                else
                {
                    incString = incString.Replace("[PromptsFolderLink]", "PromptsFolderLink Not found. Please populate this field before generating an email.");
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[PromptsFolderLink]", "PromptsFolderLink Exception. Contact Cookbook Admin.");
            }
            //greatvoice prompts section
            try
            {
                if (incString.Contains("[FullPromptCosts]") || incString.Contains("[PromptLanguages]") || incString.Contains("[TotalRecordingFees]") || incString.Contains("[RecordingStudio]"))
                {
                    if (db.PromptDetails.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        incString = incString.Replace("[RecordingStudio]", "GreatVoice"); //(smm) db.PromptDetails.First(g => g.project_id.Equals(Convert.ToInt32(filter))).recording_studio);
                        var    allEntries     = db.PromptDetails.Where(e => e.project_id.Equals(Convert.ToInt32(filter)));
                        var    allEntriesList = allEntries.ToList();
                        string buildingString = "";
                        string allLanguages   = "";
                        var    totalCosts     = 0.00;

                        //(smm) grab the CD Fee and add it to totalCosts first
                        string CDFee = db.PromptWorksheets.First(f => f.project_id.Equals(Convert.ToInt32(filter))).great_voice_cd_fee;
                        if (!isNull(CDFee))
                        {
                            CDFee       = CDFee.Replace("$", "0");
                            totalCosts += Convert.ToDouble(CDFee);
                        }

                        foreach (PromptDetail currentItem in allEntriesList)
                        {
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.setup_fee + "&nbsp;" + currentItem.language + "&nbsp;Setup<br />";
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.prompt_fee + "&nbsp;" + currentItem.language + "&nbsp;Prompts<br />";
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;<u>" + currentItem.transfer_fee + "</u>&nbsp;" + currentItem.language + "&nbsp;Transfer<br />";
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.total_recording_fee + "&nbsp;" + currentItem.language + "&nbsp;Recording<br /><br />";
                            string currentItemFee = currentItem.total_recording_fee;
                            allLanguages  += currentItem.language + ", ";
                            currentItemFee = currentItemFee.Replace("$", "0");
                            totalCosts    += Convert.ToDouble(currentItemFee);
                        }
                        allLanguages = allLanguages.Substring(0, allLanguages.Length - 2);
                        if (allEntriesList.Count > 1)
                        {
                            allLanguages = allLanguages.Insert(allLanguages.LastIndexOf(" "), " and ");
                        }
                        incString = incString.Replace("[PromptLanguages]", allLanguages);
                        incString = incString.Replace("[TotalRecordingFees]", totalCosts.ToString("N2"));

                        //(smm) Print the CD Fee if it applies
                        if (!isNull(CDFee))
                        {
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + db.PromptWorksheets.First(f => f.project_id.Equals(Convert.ToInt32(filter))).great_voice_cd_fee + "&nbsp;CD Prep / Delivery";
                        }
                        // ath 11-5-12 no longer located in promptDetailsbuildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + db.PromptDetails.First(f => f.project_id.Equals(Convert.ToInt32(filter))).cd_fee + "&nbsp;CD Prep / Delivery";

                        incString = incString.Replace("[FullPromptCosts]", buildingString);
                    }
                    else
                    {
                        incString = incString.Replace("[FullPromptCosts]", "{Prompt Details Not Found}");
                        incString = incString.Replace("[PromptLanguages]", "{Prompt Languages Not Found}");
                        incString = incString.Replace("[TotalRecordingFees]", "{Total Recording Fees Not Found}");
                        incString = incString.Replace("[RecordingStudio]", "{Recording Studio Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[FullPromptCosts]", "{Prompt Details Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[PromptLanguages]", "{Prompt Languages Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[TotalRecordingFees]", "{Total Recording Fees Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[RecordingStudio]", "{Recording Studio Exception. Contact Cookbook Admin.}");
            }

            //GM Voice Prompts PO Request
            try
            {
                if (incString.Contains("[GMVoicesVendor]") || incString.Contains("[GMVoicesTotalRecordingFees]") || incString.Contains("[GMVoicesFullPromptCosts]"))
                {
                    if (db.GMVoicePromptDetails.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        incString = incString.Replace("[GMVoicesVendor]", "GM Voices");
                        var    allEntries     = db.GMVoicePromptDetails.Where(e => e.project_id.Equals(Convert.ToInt32(filter)));
                        var    allEntriesList = allEntries.ToList();
                        string buildingString = "";
                        var    totalCosts     = 0.00;

                        foreach (GMVoicePromptDetail currentItem in allEntriesList)
                        {
                            buildingString += currentItem.setup_fee.Contains("$") ? "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.setup_fee + "&nbsp;" + currentItem.language + "&nbsp;Setup<br />" : "&nbsp;&nbsp;&nbsp;&nbsp;$" + currentItem.setup_fee + "&nbsp;" + currentItem.language + "&nbsp;Setup<br />";
                            buildingString += currentItem.translation_fee.Contains("$") ? "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.translation_fee + "&nbsp;" + currentItem.language + "&nbsp;Translation<br />" : "&nbsp;&nbsp;&nbsp;&nbsp;$" + currentItem.translation_fee + "&nbsp;" + currentItem.language + "&nbsp;Translation<br />";
                            buildingString += currentItem.delivery_fee.Contains("$") ? "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.delivery_fee + "&nbsp;" + currentItem.language + "&nbsp;Delivery<br />" : "&nbsp;&nbsp;&nbsp;&nbsp;$" + currentItem.delivery_fee + "&nbsp;" + currentItem.language + "&nbsp;Delivery<br />";
                            buildingString += currentItem.recording1_fee.Contains("$") ? "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.recording1_fee + "&nbsp;" + currentItem.language + "&nbsp;Recording 1-2<br />" : "&nbsp;&nbsp;&nbsp;&nbsp;$" + currentItem.recording1_fee + "&nbsp;" + currentItem.language + "&nbsp;Recording 1-2<br />";
                            buildingString += currentItem.recording3_fee.Contains("$") ? "&nbsp;&nbsp;&nbsp;&nbsp;<u>" + currentItem.recording3_fee + "&nbsp;" + currentItem.language + "&nbsp;Recording 3+</u><br />" : "&nbsp;&nbsp;&nbsp;&nbsp;<u>$" + currentItem.recording3_fee + "&nbsp;" + currentItem.language + "&nbsp;Recording 3+</u><br />";
                            buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + currentItem.total_recording_fee + "&nbsp;" + currentItem.language + "&nbsp;Total Recording Fee<br /><br />";
                            string currentItemFee = currentItem.total_recording_fee;
                            currentItemFee = currentItemFee.Replace("$", "0");
                            totalCosts    += Convert.ToDouble(currentItemFee);
                        }
                        incString = incString.Replace("[GMVoicesTotalRecordingFees]", totalCosts.ToString("N2"));

                        incString = incString.Replace("[GMVoicesFullPromptCosts]", buildingString);
                    }
                    else
                    {
                        incString = incString.Replace("[GMVoicesVendor]", "{Prompt GM Voices Details Not Found}");
                        incString = incString.Replace("[GMVoicesTotalRecordingFees]", "{Prompt GM Voices Details Not Found}");
                        incString = incString.Replace("[GMVoicesFullPromptCosts]", "{Prompt GM Voices Details Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[GMVoicesVendor]", "{Prompt GM Voices Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[GMVoicesTotalRecordingFees]", "{Prompt GM Voices Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[GMVoicesFullPromptCosts]", "{Prompt GM Voices Exception. Contact Cookbook Admin.}");
            }



            //GM Voice Prompts
            try
            {
                if (incString.Contains("[GMVoicesPromptNumLangInfo]") || incString.Contains("[GMVoicesPromptLangVoiceTalentInfo]"))
                {
                    if (db.GMVoicePromptDetails.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        var    allEntries          = db.GMVoicePromptDetails.Where(e => e.project_id.Equals(Convert.ToInt32(filter)));
                        var    allEntriesList      = allEntries.ToList();
                        string buildingString      = "";
                        string endingString        = " - with ";
                        var    totalPrompts        = 0;
                        string buildingString2     = "<b>";
                        int    endingStringCounter = 0;
                        foreach (GMVoicePromptDetail currentItem in allEntriesList)
                        {
                            totalPrompts   += Convert.ToInt32(currentItem.prompts_recorded);
                            buildingString += "[" + currentItem.prompts_recorded + "] " + currentItem.language + " / ";
                            if (!currentItem.language.Contains("English"))
                            {
                                endingString += currentItem.language + ", ";
                                endingStringCounter++;
                            }

                            buildingString2 += currentItem.language + " (" + currentItem.recording_studio + ")<br>";
                        }
                        buildingString2 += "</b>";
                        endingString     = endingString.Substring(0, endingString.Length - 2);
                        buildingString   = buildingString.Substring(0, buildingString.Length - 2);

                        if (endingStringCounter > 1)
                        {
                            endingString = endingString.Insert(endingString.LastIndexOf(" "), " and ");
                        }
                        if (endingStringCounter > 0)
                        {
                            endingString   += " translations";
                            buildingString += endingString;
                        }
                        buildingString = totalPrompts + " - " + buildingString;
                        incString      = incString.Replace("[GMVoicesPromptNumLangInfo]", buildingString);
                        incString      = incString.Replace("[GMVoicesPromptLangVoiceTalentInfo]", buildingString2);
                    }
                    else
                    {
                        incString = incString.Replace("[GMVoicesPromptNumLangInfo]", "{Prompt GM Voices Details Not Found}");
                        incString = incString.Replace("[GMVoicesPromptLangVoiceTalentInfo]", "{Prompt GM Voices Details Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[GMVoicesPromptNumLangInfo]", "{Prompt GM Voices Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[GMVoicesPromptLangVoiceTalentInfo]", "{Prompt GM Voices Exception. Contact Cookbook Admin.}");
            }



            //SWD schedules

            try
            {
                if (incString.Contains("[ScheduledUATDelivery]") || incString.Contains("[ScheduledCFDocsApproval]") || incString.Contains("[ScheduledCFDocsToCustomer]") ||
                    incString.Contains("[ScheduledBAComplete]") || incString.Contains("[ScheduledBAStart]"))
                {
                    if (db.SWDSchedules.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        incString = incString.Replace("[ScheduledUATDelivery]", db.SWDSchedules.First(g => g.project_id.Equals(Convert.ToInt32(filter))).scheduled_uat_delivery);
                        incString = incString.Replace("[ScheduledCFDocsApproval]", db.SWDSchedules.First(g => g.project_id.Equals(Convert.ToInt32(filter))).scheduled_docs_approval);
                        incString = incString.Replace("[ScheduledCFDocsToCustomer]", db.SWDSchedules.First(g => g.project_id.Equals(Convert.ToInt32(filter))).scheduled_docs_to_customer);
                        incString = incString.Replace("[ScheduledBAComplete]", db.SWDSchedules.First(g => g.project_id.Equals(Convert.ToInt32(filter))).scheduled_ba_complete);
                        incString = incString.Replace("[ScheduledBAStart]", db.SWDSchedules.First(g => g.project_id.Equals(Convert.ToInt32(filter))).scheduled_ba_start);
                    }
                    else
                    {
                        incString = incString.Replace("[ScheduledUATDelivery]", "{Scheduled UAT Delivery Not Found}");
                        incString = incString.Replace("[ScheduledCFDocsApproval]", "{Scheduled CF Docs Approval Not Found}");
                        incString = incString.Replace("[ScheduledCFDocsToCustomer]", "{Scheduled CF Docs To Customer Not Found}");
                        incString = incString.Replace("[ScheduledBAComplete]", "{Scheduled BA Complete Not Found}");
                        incString = incString.Replace("[ScheduledBAStart]", "{Scheduled BA Start Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[ScheduledUATDelivery]", "{Scheduled UAT Delivery Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[ScheduledCFDocsApproval]", "{Scheduled CF Docs Approval Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[ScheduledCFDocsToCustomer]", "{Scheduled CF Docs To Customer Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[ScheduledBAComplete]", "{Scheduled BA Complete Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[ScheduledBAStart]", "{Scheduled BA Start Exception. Contact Cookbook Admin.}");
            }



            try
            {
                if (incString.Contains("[ScheduledDevComplete]") || incString.Contains("[ScheduledDevStart]"))
                {
                    if (db.SWDSchedules.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        //dev start/complete
                        DateTime earliestDate = Convert.ToDateTime("01/01/2099");
                        DateTime latestDate   = Convert.ToDateTime("01/01/1099");
                        if (db.SWDAssessments.Count(h => h.project_id.Equals(Convert.ToInt32(filter)) && h.assessment_type_id.Equals(db.AssessmentTypes.Single(i => i.type.Equals("Coding")).assessment_type_id)) > 0)
                        {
                            var codingList = db.SWDAssessments.Where(h => h.project_id.Equals(Convert.ToInt32(filter)) && h.assessment_type_id.Equals(db.AssessmentTypes.Single(i => i.type.Equals("Coding")).assessment_type_id)).ToList();
                            foreach (SWDAssessment a in codingList)
                            {
                                DateTime result;
                                if (DateTime.TryParseExact(a.scheduled_start_date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out result))
                                {
                                    //scheduled start date IS a date, not a string
                                    if (DateTime.Compare(earliestDate, Convert.ToDateTime(a.scheduled_start_date)) > 0)
                                    {
                                        //earliestDate is LATER than the current item's date
                                        earliestDate = Convert.ToDateTime(a.scheduled_start_date);
                                    }
                                }
                                if (DateTime.TryParseExact(a.scheduled_complete, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out result))
                                {
                                    //scheduled complete date IS a date, not a string
                                    if (DateTime.Compare(latestDate, Convert.ToDateTime(a.scheduled_complete)) < 0)
                                    {
                                        //latestDate is EARLIER than current item's date
                                        latestDate = Convert.ToDateTime(a.scheduled_complete);
                                    }
                                }
                            }
                        }
                        if (db.SWDAssessments.Count(h => h.project_id.Equals(Convert.ToInt32(filter)) && h.assessment_type_id.Equals(db.AssessmentTypes.Single(i => i.type.Equals("MIS Other")).assessment_type_id)) > 0)
                        {
                            var codingList = db.SWDAssessments.Where(h => h.project_id.Equals(Convert.ToInt32(filter)) && h.assessment_type_id.Equals(db.AssessmentTypes.Single(i => i.type.Equals("MIS Other")).assessment_type_id)).ToList();
                            foreach (SWDAssessment a in codingList)
                            {
                                DateTime result;
                                if (DateTime.TryParseExact(a.scheduled_start_date, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out result))
                                {
                                    //scheduled start date IS a date, not a string
                                    if (DateTime.Compare(earliestDate, Convert.ToDateTime(a.scheduled_start_date)) > 0)
                                    {
                                        //earliestDate is LATER than the current item's date
                                        earliestDate = Convert.ToDateTime(a.scheduled_start_date);
                                    }
                                }

                                if (DateTime.TryParseExact(a.scheduled_complete, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out result))
                                {
                                    //scheduled complete date IS a date, not a string
                                    if (DateTime.Compare(latestDate, Convert.ToDateTime(a.scheduled_complete)) < 0)
                                    {
                                        //latestDate is EARLIER than current item's date
                                        latestDate = Convert.ToDateTime(a.scheduled_complete);
                                    }
                                }
                            }
                        }

                        if (earliestDate == Convert.ToDateTime("01/01/2099"))
                        {
                            incString = incString.Replace("[ScheduledDevStart]", "{Scheduled Dev Start Not Found}");
                        }
                        else
                        {
                            incString = incString.Replace("[ScheduledDevStart]", earliestDate.ToString("MM/dd/yyyy").Substring(0, 10));
                        }
                        if (latestDate == Convert.ToDateTime("01/01/1099"))
                        {
                            incString = incString.Replace("[ScheduledDevComplete]", "{Scheduled Dev Complete Not Found}");
                        }
                        else
                        {
                            incString = incString.Replace("[ScheduledDevComplete]", latestDate.ToString("MM/dd/yyyy").Substring(0, 10));
                        }
                    }
                    else
                    {
                        incString = incString.Replace("[ScheduledDevComplete]", "{Scheduled Dev Complete Not Found}");
                        incString = incString.Replace("[ScheduledDevStart]", "{Scheduled Dev Start Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[ScheduledDevComplete]", "{Scheduled Dev Complete Exception. Contact Cookbook Admin.}");
                incString = incString.Replace("[ScheduledDevStart]", "{Scheduled Dev Start Exception. Contact Cookbook Admin.}");
            }

            //UATProdInstall section
            try
            {
                if (incString.Contains("[UATProdInstallProdDate]"))
                {
                    if (db.UatProdInstalls.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        if (db.UatProdInstalls.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).uat_date != null && db.UatProdInstalls.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).uat_date != "")
                        {
                            incString = incString.Replace("[UATProdInstallProdDate]", db.UatProdInstalls.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).uat_date);
                        }
                        else
                        {
                            incString = incString.Replace("[UATProdInstallProdDate]", "{UAT Prod Install Prod Date Not Found}");
                        }
                    }
                    else
                    {
                        incString = incString.Replace("[UATProdInstallProdDate]", "{UAT Prod Install Prod Date Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[UATProdInstallProdDate]", "{UAT Prod Install Prod Date Exception. Contact Cookbook Admin.}");
            }


            try
            {
                if (incString.Contains("[UATProdInstallXLSAndETMFiles]"))
                {
                    if (db.ProjectRequirements.Count(d => d.project_id.Equals(Convert.ToInt32(filter)) && d.RequirementType.type.Equals("Table")) > 0)
                    {
                        string buildingString     = "";
                        var    tableReqsInUATList = db.ProjectRequirements.Where(d => d.project_id.Equals(Convert.ToInt32(filter)) && d.RequirementType.type.Equals("Table")).ToList();
                        for (int i = 0; i < tableReqsInUATList.Count; i++)
                        {
                            if (tableReqsInUATList[i].filename.Contains(".xls") || tableReqsInUATList[i].filename.Contains(".etm") && !tableReqsInUATList[i].filename.Contains("_def"))
                            {
                                buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + tableReqsInUATList[i].filename + "<br />";
                            }
                        }
                        incString = incString.Replace("[UATProdInstallXLSAndETMFiles]", buildingString);
                    }
                    else
                    {
                        incString = incString.Replace("[UATProdInstallXLSAndETMFiles]", "{UAT Prod Install XLS and ETM file names Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[UATProdInstallXLSAndETMFiles]", "{UAT Prod Install XLS and ETM file names exception. Contact Cookbook Admin.}");
            }

            //BuffetProdInstall section
            try
            {
                if (incString.Contains("[BuffetProdInstallProdDate]"))
                {
                    if (db.ProdInstallationBuffets.Count(d => d.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        if (db.ProdInstallationBuffets.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).date != null && db.ProdInstallationBuffets.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).date != "")
                        {
                            incString = incString.Replace("[BuffetProdInstallProdDate]", db.ProdInstallationBuffets.Single(j => j.project_id.Equals(Convert.ToInt32(filter))).date);
                        }
                        else
                        {
                            incString = incString.Replace("[BuffetProdInstallProdDate]", "{Buffet Prod Install Prod Date Not Found}");
                        }
                    }
                    else
                    {
                        incString = incString.Replace("[BuffetProdInstallProdDate]", "{Buffet Prod Install Prod Date Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[BuffetProdInstallProdDate]", "{Buffet Prod Install Prod Date Exception. Contact Cookbook Admin.}");
            }

            try
            {
                if (incString.Contains("[BuffetProdInstallXLSAndETMFiles]"))
                {
                    if (db.BuffetProjectRequirements.Count(d => d.project_id.Equals(Convert.ToInt32(filter)) && d.RequirementType.type.Equals("Table")) > 0)
                    {
                        string buildingString        = "";
                        var    tableReqsInBuffetList = db.BuffetProjectRequirements.Where(d => d.project_id.Equals(Convert.ToInt32(filter)) && d.RequirementType.type.Equals("Table")).ToList();
                        for (int i = 0; i < tableReqsInBuffetList.Count; i++)
                        {
                            if (tableReqsInBuffetList[i].filename.Contains(".xls") || tableReqsInBuffetList[i].filename.Contains(".etm") && !tableReqsInBuffetList[i].filename.Contains("_def"))
                            {
                                buildingString += "&nbsp;&nbsp;&nbsp;&nbsp;" + tableReqsInBuffetList[i].filename + "<br />";
                            }
                        }
                        incString = incString.Replace("[BuffetProdInstallXLSAndETMFiles]", buildingString);
                    }
                    else
                    {
                        incString = incString.Replace("[BuffetProdInstallXLSAndETMFiles]", "{Buffet Prod Install XLS and ETM file names Not Found}");
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[BuffetProdInstallXLSAndETMFiles]", "{Buffet Prod Install XLS and ETM file names exception. Contact Cookbook Admin.}");
            }

            //linked projects section
            try
            {
                if (incString.Contains("[BuffetProdInstallLinkedProjects]"))
                {
                    if (db.ProjectInformations.Count(k => k.project_id.Equals(Convert.ToInt32(filter))) > 0)
                    {
                        string buildingLinkedProjStr = db.ProjectInformations.First(k => k.project_id.Equals(Convert.ToInt32(filter))).project_number + "&nbsp;&nbsp;&nbsp;&nbsp;" +
                                                       db.ProjectInformations.First(l => l.project_id.Equals(Convert.ToInt32(filter))).project_name + "<br />";
                        //grab linked projects from this project's linked_projects info
                        string linkedProjsStr = db.ProjectInformations.First(k => k.project_id.Equals(Convert.ToInt32(filter))).linked_projects;
                        if (linkedProjsStr.Contains(','))
                        {
                            var linkedProjsList = linkedProjsStr.Split(',');
                            foreach (string currProjNumber in linkedProjsList)
                            {
                                if (db.ProjectInformations.Count(a => a.project_number.Equals(currProjNumber.Trim())) > 0)
                                {
                                    buildingLinkedProjStr += currProjNumber + "&nbsp;&nbsp;&nbsp;&nbsp;" + db.ProjectInformations.First(k => k.project_number.Equals(currProjNumber.Trim())).project_name;
                                    buildingLinkedProjStr += "<br />";
                                }
                            }
                            incString = incString.Replace("[BuffetProdInstallLinkedProjects]", buildingLinkedProjStr);
                        }
                        else
                        {
                            if (db.ProjectInformations.Count(a => a.project_number.Equals(linkedProjsStr.Trim())) > 0)
                            {
                                buildingLinkedProjStr += linkedProjsStr + "&nbsp;&nbsp;&nbsp;&nbsp;" + db.ProjectInformations.First(k => k.project_number.Equals(linkedProjsStr.Trim())).project_name;
                                buildingLinkedProjStr += "<br />";
                            }
                        }
                        incString = incString.Replace("[BuffetProdInstallLinkedProjects]", buildingLinkedProjStr);
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[BuffetProdInstallLinkedProjects]", "{Buffet Prod Install Linked Projects Exception. Contact Cookbook Admin.}");
            }

            try
            {
                if (incString.Contains("[BuffetProdInstallMasterProjectNumber]"))
                {
                    if (db.ProjectInformations.First(k => k.project_id.Equals(Convert.ToInt32(filter))).link_type != "Master")
                    {
                        incString = incString.Replace("[BuffetProdInstallMasterProjectNumber]", "{Please Generate This Email From The Master Project}");
                    }
                    else
                    {
                        incString = incString.Replace("[BuffetProdInstallMasterProjectNumber]", db.ProjectInformations.First(k => k.project_id.Equals(Convert.ToInt32(filter))).project_number);
                    }
                }
            }
            catch (Exception)
            {
                incString = incString.Replace("[BuffetProdInstallMasterProjectNumber]", "{Exception in MasterProjectNumber. Contact Cookbook Admin.}");
            }

            //contacts -- each one added here needs to be added to the parseEmailString below also!!! however this should be all of them...
            if (incString.Contains("[USANDevPM"))
            {
                incString = findContact(incString, "[USANDevPM]", "USAN Dev PM", db, filter);
            }
            if (incString.Contains("[USANTC"))
            {
                incString = findContact(incString, "[USANTC]", "USAN TC", db, filter);
            }
            if (incString.Contains("[USANBA"))
            {
                incString = findContact(incString, "[USANBA]", "USAN BA", db, filter);
            }
            if (incString.Contains("[USANDeveloper"))
            {
                incString = findContact(incString, "[USANDeveloper]", "USAN Developer", db, filter);
            }
            if (incString.Contains("[USANMIS"))
            {
                incString = findContact(incString, "[USANMIS]", "USAN MIS", db, filter);
            }
            if (incString.Contains("[USANQA"))
            {
                incString = findContact(incString, "[USANQA]", "USAN QA", db, filter);
            }
            if (incString.Contains("[USANOpsPM"))
            {
                incString = findContact(incString, "[USANOpsPM]", "USAN Ops PM", db, filter);
            }
            if (incString.Contains("[USANTLSIP"))
            {
                incString = findContact(incString, "[USANTLSIP]", "USAN TLS-IP", db, filter);
            }
            if (incString.Contains("[USANTLSSaaS"))
            {
                incString = findContact(incString, "[USANTLSSaaS]", "USAN TLS-SaaS", db, filter);
            }
            if (incString.Contains("[USANSystemsEngineer"))
            {
                incString = findContact(incString, "[USANSystemsEngineer]", "USAN Systems Engineer", db, filter);
            }
            if (incString.Contains("[CustomerPM"))
            {
                incString = findContact(incString, "[CustomerPM]", "Customer PM", db, filter);
            }
            if (incString.Contains("[CustomerRFQ"))
            {
                incString = findContact(incString, "[CustomerRFQ]", "Customer RFQ", db, filter);
            }
            if (incString.Contains("[CustomerTC"))
            {
                incString = findContact(incString, "[CustomerTC]", "Customer TC", db, filter);
            }
            if (incString.Contains("[CustomerHost"))
            {
                incString = findContact(incString, "[CustomerHost]", "Customer Host", db, filter);
            }
            if (incString.Contains("[CustomerTesting"))
            {
                incString = findContact(incString, "[CustomerTesting]", "Customer Testing", db, filter);
            }

            return(incString);
        }
Esempio n. 12
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string filter       = context.Request.Params.Get("project_id");
            string user_name    = context.Request.Params.Get("user_name");
            string exportAdd    = context.Request.Params.Get("export_add");
            string exportChange = context.Request.Params.Get("export_change");
            string exportRemove = context.Request.Params.Get("export_remove");

            if (!isNull(filter) && filter != "0")
            {
                using (new ImpersonateUser("cookbook", "USANAD", "987-oiu8"))
                {
                    ProjectInformation projInfo = db.ProjectInformations.Single(a => a.project_id.Equals(int.Parse(filter)));

                    string folder = projInfo.project_folder;
                    if (folder == "" || folder == null)
                    {
                        return(new PagedData("Error - Project Folder (on the Summary Tab) Must Be Populated"));
                    }
                    if ((folder.Reverse()).ToString().Substring(0, 1) != "\\") //add a slash to the network path if it doesn't already exist or it will be put in the parent dir
                    {
                        folder = folder + "\\";
                    }

                    string type = exportAdd == "true" ? "Add" : "";
                    type += exportChange == "true" ? "Change" : "";
                    type += exportRemove == "true" ? "Remove" : "";


                    string filename = projInfo.project_name.Replace(' ', '_') + "_" + type + "DnisRouting" + DateTime.Today.Year + DateTime.Today.Month + DateTime.Today.Day +
                                      "_" + DateTime.Now.Hour + DateTime.Now.Minute + ".xls";
                    string file = folder + filename;

                    Workbook  workbook          = new Workbook();
                    Worksheet trafficroutingTab = new Worksheet("Routing Requirements Template");

                    /*
                     * fill first 200 cells with null data - this is a workaround using the ExcelLibrary so that a warning
                     * prompt will not show when opening the file. File needs to be >6000 bytes for the warning not to show up...don't ask me...
                     */
                    for (var k = 0; k < 200; k++)
                    {
                        trafficroutingTab.Cells[k, 0] = new Cell(null);
                    }


                    //set up the column headers (titles)
                    trafficroutingTab.Cells[0, 0]  = new Cell("Type (Add/Change/Remove)");
                    trafficroutingTab.Cells[0, 1]  = new Cell("New/Existing DNIS");
                    trafficroutingTab.Cells[0, 2]  = new Cell("App To Be Routed To");
                    trafficroutingTab.Cells[0, 3]  = new Cell("Platform TO");
                    trafficroutingTab.Cells[0, 4]  = new Cell("Description");
                    trafficroutingTab.Cells[0, 5]  = new Cell("App To Be Removed From");
                    trafficroutingTab.Cells[0, 6]  = new Cell("Platform FROM");
                    trafficroutingTab.Cells[0, 7]  = new Cell("USAN Prod Routing Date");
                    trafficroutingTab.Cells[0, 8]  = new Cell("USAN Prod Routing Time");
                    trafficroutingTab.Cells[0, 9]  = new Cell("DNIS Table Prod Load Date");
                    trafficroutingTab.Cells[0, 10] = new Cell("DNIS Table Prod Load Time");
                    trafficroutingTab.Cells[0, 11] = new Cell("Carrier Prod Routing Date");
                    trafficroutingTab.Cells[0, 12] = new Cell("Carrier Prod Routing Time");
                    trafficroutingTab.Cells[0, 13] = new Cell("Alias");

                    int cellCounter1 = 1;
                    int cellCounter2 = 1;

                    if (exportAdd == "true")
                    {
                        string   totalGridResults     = grabTrafficRoutingDNIS(db, filter, "add");
                        string[] gridResultsSeparated = totalGridResults.Split('|');

                        var buildingList = db.RoutingRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.Equals("add")).ToList();

                        for (int x = 0; x < gridResultsSeparated.Length; x++)
                        {
                            int currentCell    = cellCounter1;
                            var individualCell = gridResultsSeparated[x].Split(';');

                            for (int i = 0; i < individualCell.Length; i++)
                            {
                                trafficroutingTab.Cells[currentCell, i] = new Cell(individualCell[i].Trim());
                            }
                            cellCounter1 = currentCell + 1;
                        }
                    }

                    if (exportChange == "true")
                    {
                        string   totalGridResults     = grabTrafficRoutingDNIS(db, filter, "change");
                        string[] gridResultsSeparated = totalGridResults.Split('|');

                        var buildingList = db.RoutingRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.Equals("change")).ToList();

                        for (int x = 0; x < gridResultsSeparated.Length; x++)
                        {
                            int currentCell    = cellCounter1 + x;
                            var individualCell = gridResultsSeparated[x].Split(';');
                            for (int i = 0; i < individualCell.Length; i++)
                            {
                                trafficroutingTab.Cells[currentCell, i] = new Cell(individualCell[i].Trim());
                            }
                            cellCounter2 = currentCell + 1;
                        }
                    }

                    if (cellCounter2 > 1)
                    {
                        cellCounter1 = cellCounter2;
                    }

                    if (exportRemove == "true")
                    {
                        string   totalGridResults     = grabTrafficRoutingDNIS(db, filter, "delete");
                        string[] gridResultsSeparated = totalGridResults.Split('|');

                        var buildingList = db.RoutingRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.Equals("remove")).ToList();

                        for (int x = 0; x < gridResultsSeparated.Length; x++)
                        {
                            int currentCell    = cellCounter1 + x;
                            var individualCell = gridResultsSeparated[x].Split(';');

                            for (int i = 0; i < individualCell.Length; i++)
                            {
                                trafficroutingTab.Cells[currentCell, i] = new Cell(individualCell[i].Trim());
                            }
                        }
                    }



                    trafficroutingTab.Cells.ColumnWidth[0, 14] = 8000;

                    workbook.Worksheets.Add(trafficroutingTab);


                    try
                    {
                        workbook.Save(file);
                        return(new PagedData("Grid Data Exported to " + folder + " with the filename: " + filename));
                    }
                    catch (Exception e)
                    {
                        return(new PagedData("Project Unable To Be Exported Contact Cookbook Admin - Error: " + e.Message, false));
                    }
                }
            }
            else
            {
                return(new PagedData("ExportTrafficRoutingGrid expects a project id!"));
            }
        }