Exemple #1
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string readOnly = context.Request.Params.Get("read_only");

            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }

            IQueryable <MISUpdateDNI> q = db.MISUpdateDNIs;

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));


            switch (context.Request.RequestType)
            {
            case "GET":
            {
                string filter = context.Request.Params.Get("mis_update_id");
                if (!isNull(filter))
                {
                    q = q.Where(a => a.mis_update_id.Equals(int.Parse(filter)) && a.remove_from.Length > 1 && a.reroute_to.Length > 1);
                }

                return(new PagedData(q.Select(a => new { a.mis_updatednis_id, a.mis_update_id, a.dnis, a.remove_from, a.platform, a.description, a.effective_date, a.reroute_to, a.platform_from })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    MISUpdateDNI record = new MISUpdateDNI();
                    record.mis_update_id = (int)obj["mis_update_id"];
                    record.dnis          = (String)obj["dnis"];
                    record.remove_from   = (String)obj["remove_from"];
                    if (obj["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)obj["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform"])[0];
                        for (int i = 1; i < ((JArray)obj["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description    = (String)obj["description"];
                    record.effective_date = (String)obj["effective_date"];
                    record.reroute_to     = (String)obj["reroute_to"];
                    if (obj["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)obj["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform_from"])[0];
                        for (int i = 1; i < ((JArray)obj["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }

                    db.MISUpdateDNIs.InsertOnSubmit(record);
                    db.SubmitChanges();

                    return(new PagedData(new { record.mis_updatednis_id, record.mis_update_id, record.dnis, record.remove_from, record.platform, record.description, record.effective_date, record.reroute_to, record.platform_from }));
                }

                JArray        objs = (JArray)blob["rows"];
                List <Object> list = new List <Object>();
                for (int j = 0; j < objs.Count; j++)
                {
                    MISUpdateDNI record = new MISUpdateDNI();
                    record.mis_update_id = (int)objs[j]["mis_update_id"];
                    record.dnis          = (String)objs[j]["dnis"];
                    record.remove_from   = (String)objs[j]["remove_from"];
                    if (objs[j]["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)objs[j]["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description    = (String)objs[j]["description"];
                    record.effective_date = (String)objs[j]["effective_date"];
                    record.reroute_to     = (String)objs[j]["reroute_to"];
                    if (objs[j]["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)objs[j]["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform_from"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }

                    db.MISUpdateDNIs.InsertOnSubmit(record);
                    db.SubmitChanges();

                    list.Add(new { record.mis_updatednis_id, record.mis_update_id, record.dnis, record.remove_from, record.platform, record.description, record.effective_date, record.reroute_to, record.platform_from });
                }

                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    MISUpdateDNI record = db.MISUpdateDNIs.Single(a => a.mis_updatednis_id.Equals((int)obj["mis_updatednis_id"]));
                    record.dnis = (String)obj["dnis"];
                    if (obj["remove_from"] != null)
                    {
                        record.remove_from = (String)obj["remove_from"];
                    }
                    //record.platform = (string)obj["platform"];

                    if (obj["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)obj["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform"])[0];
                        for (int i = 1; i < ((JArray)obj["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description    = (String)obj["description"];
                    record.effective_date = (String)obj["effective_date"];
                    record.reroute_to     = (String)obj["reroute_to"];
                    if (obj["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)obj["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform_from"])[0];
                        for (int i = 1; i < ((JArray)obj["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }

                    db.SubmitChanges();

                    return(new PagedData(new { record.mis_updatednis_id, record.mis_update_id, record.dnis, record.remove_from, record.platform, record.description, record.effective_date, record.reroute_to, record.platform_from }));
                }

                JArray        objs = (JArray)blob["rows"];
                List <Object> list = new List <Object>();
                for (int j = 0; j < objs.Count; j++)
                {
                    MISUpdateDNI record = db.MISUpdateDNIs.Single(a => a.mis_updatednis_id.Equals((int)objs[j]["mis_updatednis_id"]));
                    record.dnis        = (String)objs[j]["dnis"];
                    record.remove_from = (String)objs[j]["remove_from"];
                    if (objs[j]["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)objs[j]["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description    = (String)objs[j]["description"];
                    record.effective_date = (String)objs[j]["effective_date"];
                    record.reroute_to     = (String)objs[j]["reroute_to"];
                    if (objs[j]["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)objs[j]["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform_from"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }

                    list.Add(new { record.mis_updatednis_id, record.mis_update_id, record.dnis, record.remove_from, record.platform, record.description, record.effective_date, record.reroute_to, record.platform_from });
                }

                db.SubmitChanges();

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    MISUpdateDNI record = db.MISUpdateDNIs.Single(a => a.mis_updatednis_id.Equals((int)obj["mis_updatednis_id"]));
                    db.MISUpdateDNIs.DeleteOnSubmit(record);

                    db.SubmitChanges();

                    return(new PagedData("dnis deleted"));
                }

                JArray objs = (JArray)blob["rows"];
                for (int j = 0; j < objs.Count; j++)
                {
                    MISUpdateDNI record = db.MISUpdateDNIs.Single(a => a.mis_updatednis_id.Equals((int)objs[j]["mis_updatednis_id"]));
                    db.MISUpdateDNIs.DeleteOnSubmit(record);
                }

                db.SubmitChanges();

                return(new PagedData("dnises deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <ProjectInformation> q = db.ProjectInformations;

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));
            string  intro          = "The Traffic & Routing page had the following modifications: ";
            string  logBuilder     = "";

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

            if (!isNull(filter))
            {
                TrafficRequirement record = db.TrafficRequirements.Single(a => a.project_id.Equals(int.Parse(filter)));

                if (blob["trafficroutingAverageCallDuration"] != null)
                {
                    if (record.avg_call_duration != (String)blob["trafficroutingAverageCallDuration"])
                    {
                        logBuilder += "Average Call Duration changed from \"" + record.avg_call_duration + "\" -> \"" + (String)blob["trafficroutingAverageCallDuration"] + "\"; ";
                    }
                    record.avg_call_duration = (String)blob["trafficroutingAverageCallDuration"];
                }
                if (blob["trafficroutingBusyHourCallPercentage"] != null)
                {
                    if (record.busy_hour_call_percentage != (String)blob["trafficroutingBusyHourCallPercentage"])
                    {
                        logBuilder += "Busy-Hour Call % changed from \"" + record.busy_hour_call_percentage + "\" -> \"" + (String)blob["trafficroutingBusyHourCallPercentage"] + "\"; ";
                    }
                    record.busy_hour_call_percentage = (String)blob["trafficroutingBusyHourCallPercentage"];
                }
                if (blob["trafficroutingBusyHourCalls"] != null)
                {
                    if (record.busy_hour_calls != (String)blob["trafficroutingBusyHourCalls"])
                    {
                        logBuilder += "Busy-Hour Calls changed from \"" + record.busy_hour_calls + "\" -> \"" + (String)blob["trafficroutingBusyHourCalls"] + "\"; ";
                    }
                    record.busy_hour_calls = (String)blob["trafficroutingBusyHourCalls"];
                }
                if (blob["trafficroutingIncludedInForecast"] != null)
                {
                    if (record.forecast != (((String)blob["trafficroutingIncludedInForecast"]) == "yes" ? true : false))
                    {
                        logBuilder += "Included in Forecast changed from \"" + record.forecast + "\" -> \"" + (String)blob["trafficroutingIncludedInForecast"] + "\"; ";
                    }
                    record.forecast = (((String)blob["trafficroutingIncludedInForecast"]) == "yes" ? true : false);
                }
                if (blob["trafficroutingIncrementalCallsPerMonth"] != null)
                {
                    if (record.calls_month != (String)blob["trafficroutingIncrementalCallsPerMonth"])
                    {
                        logBuilder += "Incremental Calls / Mo. changed from \"" + record.calls_month + "\" -> \"" + (String)blob["trafficroutingIncrementalCallsPerMonth"] + "\"; ";
                    }
                    record.calls_month = (String)blob["trafficroutingIncrementalCallsPerMonth"];
                }
                if (blob["trafficroutingIncrementalMinutesPerMonth"] != null)
                {
                    if (record.min_month != (String)blob["trafficroutingIncrementalMinutesPerMonth"])
                    {
                        logBuilder += "Incremental Min. / Mo. changed from \"" + record.min_month + "\" -> \"" + (String)blob["trafficroutingIncrementalMinutesPerMonth"] + "\"; ";
                    }
                    record.min_month = (String)blob["trafficroutingIncrementalMinutesPerMonth"];
                }


                db.SubmitChanges();


                // if (permission != "PM")
                //  {
                if (logBuilder != "")
                {
                    logBuilder = logBuilder.Replace("False", "no");
                    logBuilder = logBuilder.Replace("True", "yes");
                }

                intro = (intro + logBuilder);
                intro = intro.Trim();

                if (intro.LastIndexOf(";") == intro.Length - 1)
                {
                    intro = intro.Substring(0, intro.Length - 1);
                }
                ChangeLog newLog = new ChangeLog();
                newLog.project_id  = Convert.ToInt32(filter);
                newLog.time        = DateTime.Now.ToShortTimeString();
                newLog.date        = DateTime.Now.ToShortDateString();
                newLog.tab         = "Traffic & Routing";
                newLog.user_name   = username;
                newLog.description = intro;
                if ((!db.ChangeLogs.Contains(newLog)) && (logBuilder.Length > 0))
                {
                    db.ChangeLogs.InsertOnSubmit(newLog);
                    db.SubmitChanges();
                }
                // }
                return(new PagedData("Traffic requirements saved"));
            }

            return(new PagedData("UpdateTrafficRouting.ashx required a project_id"));
        }
Exemple #3
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <SWDAssessment> q = db.SWDAssessments;

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

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);
            var     jsonSerializer        = new JsonSerializer();
            JObject blob = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));

            string readOnly = context.Request.Params.Get("read_only");

            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }
            switch (context.Request.RequestType)
            {
            case "GET":
            {
                if (!isNull(filter))
                {
                    q = q.Where(a => a.project_id == int.Parse(filter) && (
                                    a.AssessmentType.type == "Non-SWD QA" ||
                                    a.AssessmentType.type == "OSG Scripts"
                                    ));

                    return(new PagedData(q.Select(a => new
                        {
                            a.project_id,
                            a.Contact.name,
                            a.AssessmentType.type,
                            a.hours,
                            a.action,
                            a.requested_start_date,
                            a.requested_complete,
                            a.scheduled_start_date,
                            a.scheduled_complete,
                            a.actual_complete,
                            a.booked_hours,
                            a.swd_assessment_id
                        })));
                }
                else
                {
                    return(new PagedData("GetOSGAssessment expects a project_id"));
                }
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    SWDAssessment record = new SWDAssessment();

                    record.project_id           = int.Parse(filter);
                    record.Contact              = db.Contacts.Single(a => a.name.Equals("Test Guy"));
                    record.Contact.name         = "Test Guy";
                    record.action               = "";
                    record.hours                = "";
                    record.booked_hours         = "";
                    record.requested_start_date = "";
                    record.requested_complete   = "";
                    record.scheduled_start_date = "";
                    record.scheduled_complete   = "";
                    record.actual_complete      = "";
                    try
                    {
                        record.assessment_type_id = db.AssessmentTypes.Single(a => a.type == (string)obj["type"]).assessment_type_id;
                    }
                    catch (Exception)
                    {
                        record.assessment_type_id = db.AssessmentTypes.Single(a => a.type == "Non-SWD QA").assessment_type_id;
                    }
                    db.SWDAssessments.InsertOnSubmit(record);
                    db.SubmitChanges();

                    q = q.Where(a => a.project_id == int.Parse(filter) && a.swd_assessment_id == record.swd_assessment_id);

                    return(new PagedData(q.Select(a => new
                        {
                            a.swd_assessment_id,
                            a.AssessmentType.type,
                            a.action,
                            a.Contact.name,
                            a.hours,
                            a.booked_hours,
                            a.requested_start_date,
                            a.requested_complete,
                            a.scheduled_start_date,
                            a.scheduled_complete,
                            a.actual_complete
                        })));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <SWDAssessment> list = new List <SWDAssessment>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        SWDAssessment record = new SWDAssessment();

                        record.project_id           = int.Parse(filter);
                        record.Contact              = db.Contacts.Single(a => a.name.Equals("Test Guy"));
                        record.Contact.name         = "Test Guy";
                        record.action               = "";
                        record.hours                = "";
                        record.booked_hours         = "";
                        record.requested_start_date = "";
                        record.requested_complete   = "";
                        record.scheduled_start_date = "";
                        record.scheduled_complete   = "";
                        record.actual_complete      = "";
                        try
                        {
                            record.assessment_type_id = db.AssessmentTypes.Single(a => a.type == (string)objs["type"]).assessment_type_id;
                        }
                        catch (Exception)
                        {
                            record.assessment_type_id = db.AssessmentTypes.Single(a => a.type == "Non-SWD QA").assessment_type_id;
                        }

                        db.SWDAssessments.InsertOnSubmit(record);
                        db.SubmitChanges();
                        list.Add(record);
                    }
                    return(new PagedData(list));
                }
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    SWDAssessment record = db.SWDAssessments.Single(a => a.swd_assessment_id.Equals((int)obj["swd_assessment_id"]));
                    try
                    {
                        record.Contact = db.Contacts.Single(a => a.name.Equals((string)obj["name"]));
                    }
                    catch (Exception)
                    {
                        record.Contact = db.Contacts.Single(a => a.name.Equals("Test Guy"));
                    }
                    record.action               = (string)obj["action"];
                    record.hours                = (string)obj["hours"];
                    record.booked_hours         = (string)obj["booked_hours"];
                    record.requested_start_date = obj["requested_start_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["requested_start_date"]) : ((string)obj["requested_start_date"] == null ? "" : (string)obj["requested_start_date"]);
                    record.requested_complete   = obj["requested_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["requested_complete"]) : ((string)obj["requested_complete"] == null ? "" : (string)obj["requested_complete"]);
                    record.scheduled_start_date = obj["scheduled_start_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["scheduled_start_date"]) : ((string)obj["scheduled_start_date"] == null ? "" : (string)obj["scheduled_start_date"]);
                    record.scheduled_complete   = obj["scheduled_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["scheduled_complete"]) : ((string)obj["scheduled_complete"] == null ? "" : (string)obj["scheduled_complete"]);
                    record.actual_complete      = obj["actual_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["actual_complete"]) : ((string)obj["actual_complete"] == null ? "" : (string)obj["actual_complete"]);
                    db.SubmitChanges();

                    q = q.Where(a => a.project_id == int.Parse(filter) && a.swd_assessment_id == record.swd_assessment_id);

                    return(new PagedData(q.Select(a => new
                        {
                            a.swd_assessment_id,
                            a.AssessmentType.type,
                            a.action,
                            a.Contact.name,
                            a.hours,
                            a.booked_hours,
                            a.requested_start_date,
                            a.requested_complete,
                            a.scheduled_start_date,
                            a.scheduled_complete,
                            a.actual_complete
                        })));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <SWDAssessment> list = new List <SWDAssessment>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        SWDAssessment record = db.SWDAssessments.Single(a => a.swd_assessment_id.Equals((int)objs["swd_assessment_id"]));
                        try
                        {
                            record.Contact = db.Contacts.Single(a => a.name.Equals((string)objs["name"]));
                        }
                        catch (Exception)
                        {
                            record.Contact = db.Contacts.Single(a => a.name.Equals("Test Guy"));
                        }
                        record.action               = (string)objs["action"];
                        record.hours                = (string)objs["hours"];
                        record.booked_hours         = (string)objs["booked_hours"];
                        record.requested_start_date = objs["requested_start_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["requested_start_date"]) : ((string)objs["requested_start_date"] == null ? "" : (string)objs["requested_start_date"]);
                        record.requested_complete   = objs["requested_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["requested_complete"]) : ((string)objs["requested_complete"] == null ? "" : (string)objs["requested_complete"]);
                        record.scheduled_start_date = objs["scheduled_start_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["scheduled_start_date"]) : ((string)objs["scheduled_start_date"] == null ? "" : (string)objs["scheduled_start_date"]);
                        record.scheduled_complete   = objs["scheduled_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["scheduled_complete"]) : ((string)objs["scheduled_complete"] == null ? "" : (string)objs["scheduled_complete"]);
                        record.actual_complete      = objs["actual_complete"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["actual_complete"]) : ((string)objs["actual_complete"] == null ? "" : (string)objs["actual_complete"]);
                        db.SubmitChanges();
                        list.Add(record);
                    }
                    return(new PagedData(list));
                }
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    SWDAssessment record = db.SWDAssessments.Single(a => a.swd_assessment_id.Equals((int)obj["swd_assessment_id"]));
                    db.SWDAssessments.DeleteOnSubmit(record);
                    db.SubmitChanges();
                    return(new PagedData("OSG Assessment Rec Deleted"));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <SWDAssessment> list = new List <SWDAssessment>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        JObject       obj    = (JObject)blob["rows"];
                        SWDAssessment record = db.SWDAssessments.Single(a => a.swd_assessment_id.Equals((int)obj["swd_assessment_id"]));
                        db.SWDAssessments.DeleteOnSubmit(record);
                        db.SubmitChanges();
                    }
                    return(new PagedData("OSG Assessment Recs Deleted"));
                }
            }

            default:
                return(new PagedData("Error: Unsupported Http Request:  " + context.Request.RequestType + " not recognized", false));
            }
        }
Exemple #4
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <ManagerReq> q = db.ManagerReqs;

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

            if (!isNull(filter))
            {
                q = q.Where(a => a.project_id == int.Parse(filter));
            }
            else
            {
                return(new PagedData(q.Select(a => new { a.project_id, a.name })));
                //return new PagedData("GetManagerRequirements expects a project_id");
            }

            string readOnly = context.Request.Params.Get("read_only");

            if (isNull(readOnly))
            {
                return(new PagedData("read_only flag is expected"));
            }
            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }
            string username = context.Request.Params.Get("user_name");

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));


            switch (context.Request.RequestType)
            {
            case "GET":
            {
                return(new PagedData(q.Select(a => new { a.manager_req_id, a.project_id, a.@new, a.name, a.exe_file, a.pdb_file, a.notes })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject    obj    = (JObject)blob["rows"];
                    ManagerReq record = new ManagerReq();

                    record.project_id = int.Parse(filter);
                    record.name       = (string)obj["name"];
                    record.@new       = (bool)obj["new"];
                    record.exe_file   = (string)obj["exe_file"];
                    record.pdb_file   = (string)obj["pdb_file"];
                    record.notes      = (string)obj["notes"];

                    db.ManagerReqs.InsertOnSubmit(record);
                    db.SubmitChanges();

                    ChangeLog newLog = new ChangeLog();
                    newLog.project_id  = Convert.ToInt32(int.Parse(filter));
                    newLog.time        = DateTime.Now.ToShortTimeString();
                    newLog.date        = DateTime.Now.ToShortDateString();
                    newLog.tab         = "Requirements";
                    newLog.user_name   = username;
                    newLog.description = "New Manager requirement added";
                    if (!db.ChangeLogs.Contains(newLog))
                    {
                        db.ChangeLogs.InsertOnSubmit(newLog);
                        db.SubmitChanges();
                    }

                    return(new PagedData(record));
                }

                JArray            objs = (JArray)blob["rows"];
                List <ManagerReq> list = new List <ManagerReq>();
                for (int j = 0; j < objs.Count; j++)
                {
                    ManagerReq record = new ManagerReq();
                    record.project_id = int.Parse(filter);
                    record.name       = (string)objs[j]["name"];
                    record.@new       = (bool)objs[j]["new"];
                    record.exe_file   = (string)objs[j]["exe_file"];
                    record.pdb_file   = (string)objs[j]["pdb_file"];
                    record.notes      = (string)objs[j]["notes"];

                    db.ManagerReqs.InsertOnSubmit(record);
                    db.SubmitChanges();
                    list.Add(record);
                }


                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    string logBuilder = "";
                    string intro      = "Existing Manager record modified: ";

                    ManagerReq record = db.ManagerReqs.Single(a => a.manager_req_id.Equals((int)obj["manager_req_id"]));
                    if (record.name != (string)obj["name"])
                    {
                        logBuilder += "Name changed from \"" + record.name + "\" to \"" + (string)obj["name"] + "\".";
                    }
                    record.name = (string)obj["name"];
                    //record.project_id = int.Parse(filter);
                    if (record.@new != (bool)obj["new"])
                    {
                        logBuilder += "New changed from \"" + record.@new + "\" to \"" + (bool)obj["new"] + "\".";
                    }
                    record.@new = (bool)obj["new"];
                    if (record.exe_file != (string)obj["exe_file"])
                    {
                        logBuilder += "EXE File changed from \"" + record.exe_file + "\" to \"" + (string)obj["exe_file"] + "\".";
                    }
                    record.exe_file = (string)obj["exe_file"];
                    if (record.pdb_file != (string)obj["pdb_file"])
                    {
                        logBuilder += "PDB File changed from \"" + record.pdb_file + "\" to \"" + (string)obj["pdb_file"] + "\".";
                    }
                    record.pdb_file = (string)obj["pdb_file"];
                    if (record.notes != (string)obj["notes"])
                    {
                        logBuilder += "Notes changed from \"" + record.notes + "\" to \"" + (string)obj["notes"] + "\".";
                    }
                    record.notes = (string)obj["notes"];

                    db.SubmitChanges();

                    if (logBuilder != "")
                    {
                        ChangeLog newLog = new ChangeLog();
                        newLog.project_id  = Convert.ToInt32(int.Parse(filter));
                        newLog.time        = DateTime.Now.ToShortTimeString();
                        newLog.date        = DateTime.Now.ToShortDateString();
                        newLog.tab         = "Requirements";
                        newLog.user_name   = username;
                        newLog.description = intro + logBuilder;
                        if (!db.ChangeLogs.Contains(newLog))
                        {
                            db.ChangeLogs.InsertOnSubmit(newLog);
                            db.SubmitChanges();
                        }
                    }

                    return(new PagedData(record));
                }


                JArray            objs = (JArray)blob["rows"];
                List <ManagerReq> list = new List <ManagerReq>();
                for (int j = 0; j < objs.Count; j++)
                {
                    ManagerReq record = db.ManagerReqs.Single(a => a.manager_req_id.Equals((int)objs[j]["manager_req_id"]));
                    record.name = (string)objs[j]["name"];
                    //record.project_id = int.Parse(filter);
                    record.@new     = (bool)objs[j]["new"];
                    record.exe_file = (string)objs[j]["exe_file"];
                    record.pdb_file = (string)objs[j]["pdb_file"];
                    record.notes    = (string)objs[j]["notes"];

                    db.SubmitChanges();
                    list.Add(record);
                }

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    string logbuilder = "";

                    ManagerReq record = db.ManagerReqs.Single(a => a.manager_req_id.Equals((int)obj["manager_req_id"]));
                    logbuilder += "Name: \"" + record.name + "\"; New: \"" + record.@new + "\"; EXE File: \"" + record.exe_file + "\"; PDB File: \"" +
                                  record.pdb_file + "\"; Notes: \"" + record.notes + "\".";

                    db.ManagerReqs.DeleteOnSubmit(record);

                    db.SubmitChanges();

                    ChangeLog newLog = new ChangeLog();
                    newLog.project_id  = Convert.ToInt32(int.Parse(filter));
                    newLog.time        = DateTime.Now.ToShortTimeString();
                    newLog.date        = DateTime.Now.ToShortDateString();
                    newLog.tab         = "Requirements";
                    newLog.user_name   = username;
                    newLog.description = "Existing Manager Requirement deleted: " + logbuilder;
                    if (!db.ChangeLogs.Contains(newLog))
                    {
                        db.ChangeLogs.InsertOnSubmit(newLog);
                        db.SubmitChanges();
                    }

                    return(new PagedData("good"));
                }


                JArray objs = (JArray)blob["rows"];
                for (int j = 0; j < objs.Count; j++)
                {
                    ManagerReq record = db.ManagerReqs.Single(a => a.manager_req_id.Equals((int)objs[j]["manager_req_id"]));
                    db.ManagerReqs.DeleteOnSubmit(record);
                }

                db.SubmitChanges();
                return(new PagedData("ManagerReq deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <Application> q = db.Applications;

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));


            switch (context.Request.RequestType)
            {
            case "GET":
            {
                string filter = context.Request.Params.Get("name");
                if (!isNull(filter))
                {
                    q = q.Where(a => a.name.IndexOf(filter) != -1);
                }

                return(new PagedData(q.Select(a => new { a.applications_id, a.name, a.base_name, a.Product, a.Division, a.Platform, a.ServiceID })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject app = (JObject)blob["rows"];

                    Application newApp = new Application();
                    newApp.name      = (string)app["name"];
                    newApp.base_name = (string)app["base_name"];
                    newApp.Product   = app["Product"] == null ? "" : (string)app["Product"];
                    newApp.Division  = app["Division"] == null ? "" : (string)app["Division"];
                    newApp.Platform  = app["Platform"] == null ? "" : (string)app["Platform"];
                    newApp.ServiceID = app["ServiceID"] == null ? "" : (string)app["ServiceID"];

                    db.Applications.InsertOnSubmit(newApp);
                    db.SubmitChanges();

                    return(new PagedData(newApp));         //JsonConvert.SerializeObject(newApp));
                }

                JArray             apps = (JArray)blob["rows"];
                List <Application> list = new List <Application>();
                for (int j = 0; j < apps.Count; j++)
                {
                    Application newApp = new Application();
                    newApp.name      = (string)apps[j]["name"];
                    newApp.base_name = (string)apps[j]["base_name"];
                    newApp.Product   = apps[j]["Product"] == null ? "" : (string)apps[j]["Product"];
                    newApp.Division  = apps[j]["Division"] == null ? "" : (string)apps[j]["Division"];
                    newApp.Platform  = apps[j]["Platform"] == null ? "" : (string)apps[j]["Platform"];
                    newApp.ServiceID = apps[j]["ServiceID"] == null ? "" : (string)apps[j]["ServiceID"];

                    db.Applications.InsertOnSubmit(newApp);
                    list.Add(newApp);
                }

                db.SubmitChanges();

                DocumentationReq doc = new DocumentationReq();


                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject app = (JObject)blob["rows"];

                    Application app2 = db.Applications.Single(a => a.applications_id.Equals((int)app["applications_id"]));
                    app2.base_name = (string)app["base_name"];
                    app2.name      = (string)app["name"];
                    app2.Product   = app["Product"] == null ? "" : (string)app["Product"];
                    app2.Division  = app["Division"] == null ? "" : (string)app["Division"];
                    app2.Platform  = app["Platform"] == null ? "" : (string)app["Platform"];
                    app2.ServiceID = app["ServiceID"] == null ? "" : (string)app["ServiceID"];

                    db.SubmitChanges();

                    return(new PagedData(app2));
                }

                JArray             apps = (JArray)blob["rows"];
                List <Application> list = new List <Application>();
                for (int j = 0; j < apps.Count; j++)
                {
                    Application app2 = db.Applications.Single(a => a.applications_id.Equals((int)apps[j]["applications_id"]));
                    app2.base_name = (string)apps[j]["base_name"];
                    app2.name      = (string)apps[j]["name"];
                    app2.Product   = apps[j]["Product"] == null ? "" : (string)apps[j]["Product"];
                    app2.Division  = apps[j]["Division"] == null ? "" : (string)apps[j]["Division"];
                    app2.Platform  = apps[j]["Platform"] == null ? "" : (string)apps[j]["Platform"];
                    app2.ServiceID = apps[j]["ServiceID"] == null ? "" : (string)apps[j]["ServiceID"];


                    db.SubmitChanges();
                    list.Add(app2);
                }

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject app = (JObject)blob["rows"];

                    Application app2 = db.Applications.Single(a => a.applications_id.Equals((int)app["applications_id"]));
                    db.Applications.DeleteOnSubmit(app2);

                    db.SubmitChanges();

                    return(new PagedData("good"));
                }

                JArray apps = (JArray)blob["rows"];
                for (int j = 0; j < apps.Count; j++)
                {
                    Application app2 = db.Applications.Single(a => a.applications_id.Equals((int)apps[j]["applications_id"]));
                    db.Applications.DeleteOnSubmit(app2);
                }

                db.SubmitChanges();

                return(new PagedData("deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <Category> q = db.Categories;

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));


            switch (context.Request.RequestType)
            {
            case "GET":
            {
                return(new PagedData(q.Select(a => new { a.category_id, a.category1 })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Category record = new Category();
                    record.category1 = (string)obj["category1"];

                    db.Categories.InsertOnSubmit(record);
                    db.SubmitChanges();

                    return(new PagedData(record));         //JsonConvert.SerializeObject(newApp));
                }

                JArray          objs = (JArray)blob["rows"];
                List <Category> list = new List <Category>();
                for (int j = 0; j < objs.Count; j++)
                {
                    Category record = new Category();
                    record.category1 = (string)objs[j]["category1"];

                    db.Categories.InsertOnSubmit(record);
                    list.Add(record);
                }

                db.SubmitChanges();

                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Category record = db.Categories.Single(a => a.category_id.Equals((int)obj["category_id"]));
                    record.category1 = (string)obj["category1"];

                    db.SubmitChanges();

                    return(new PagedData(record));         //JsonConvert.SerializeObject(newApp));
                }

                JArray          objs = (JArray)blob["rows"];
                List <Category> list = new List <Category>();
                for (int j = 0; j < objs.Count; j++)
                {
                    Category record = db.Categories.Single(a => a.category_id.Equals((int)objs[j]["category_id"]));
                    record.category1 = (string)objs[j]["category1"];
                    db.SubmitChanges();
                    list.Add(record);
                }

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Category record = db.Categories.Single(a => a.category_id.Equals((int)obj["category_id"]));
                    db.Categories.DeleteOnSubmit(record);

                    db.SubmitChanges();

                    return(new PagedData("good"));
                }

                JArray objs = (JArray)blob["rows"];
                for (int j = 0; j < objs.Count; j++)
                {
                    Category record = db.Categories.Single(a => a.category_id.Equals((int)objs[j]["category_id"]));
                    db.Categories.DeleteOnSubmit(record);
                }

                db.SubmitChanges();

                return(new PagedData("deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
Exemple #7
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <AccessUSANReq> q = db.AccessUSANReqs;

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

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);
            var     jsonSerializer        = new JsonSerializer();
            JObject blob = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));

            string readOnly = context.Request.Params.Get("read_only");

            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }
            switch (context.Request.RequestType)
            {
            case "GET":
            {
                if (!isNull(filter))
                {
                    q = q.Where(a => a.project_id == int.Parse(filter));
                    List <Object>        recordsToReturn = new List <Object>();
                    List <AccessUSANReq> tableRecs       = q.ToList();

                    foreach (AccessUSANReq currentRec in tableRecs)
                    {
                        string[] table_permission_required = currentRec.table_permission_required.Split(',');
                        for (int i = 0; i < table_permission_required.Length; i++)
                        {
                            table_permission_required[i] = table_permission_required[i].Trim();
                        }

                        recordsToReturn.Add(new
                            {
                                currentRec.project_id,
                                currentRec.accessusan_req_id,
                                currentRec.@new,
                                currentRec.name,
                                currentRec.email,
                                currentRec.login_id,
                                currentRec.report_access_required,
                                currentRec.read_only_permission,
                                table_permission_required
                            });
                    }

                    return(new PagedData(recordsToReturn));

                    /*return new PagedData(q.Select(a => new
                     * {
                     *  a.project_id,
                     *  a.accessusan_req_id,
                     *  a.@new,
                     *  a.name,
                     *  a.email,
                     *  a.login_id,
                     *  a.table_permission_required,
                     *  a.report_access_required,
                     *  a.read_only_permission
                     * }));*/
                }
                else
                {
                    return(new PagedData("GetAccessUSANReqs expects a project_id"));
                }
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    AccessUSANReq record = new AccessUSANReq();

                    record.project_id = int.Parse(filter);
                    record.@new       = false;
                    record.name       = "Test Guy";
                    record.email      = "";
                    record.login_id   = "";
                    record.table_permission_required = "";
                    record.report_access_required    = "";
                    record.read_only_permission      = false;
                    db.AccessUSANReqs.InsertOnSubmit(record);
                    db.SubmitChanges();

                    q = q.Where(a => a.project_id == int.Parse(filter) && a.accessusan_req_id == record.accessusan_req_id);

                    return(new PagedData(q.Select(a => new
                        {
                            a.project_id,
                            a.accessusan_req_id,
                            a.@new,
                            a.name,
                            a.email,
                            a.login_id,
                            a.table_permission_required,
                            a.report_access_required,
                            a.read_only_permission
                        })));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <AccessUSANReq> list = new List <AccessUSANReq>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        AccessUSANReq record = new AccessUSANReq();

                        record.project_id = int.Parse(filter);
                        record.@new       = false;
                        record.name       = "Test Guy";
                        record.email      = "";
                        record.login_id   = "";
                        record.table_permission_required = "";
                        record.report_access_required    = "";
                        record.read_only_permission      = false;

                        db.AccessUSANReqs.InsertOnSubmit(record);
                        db.SubmitChanges();

                        list.Add(record);
                    }
                    return(new PagedData(list));
                }
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    AccessUSANReq record = db.AccessUSANReqs.Single(a => a.accessusan_req_id.Equals((int)obj["accessusan_req_id"]));
                    try
                    {
                        record.name = db.Contacts.Single(a => a.name.Equals((string)obj["name"])).name;
                    }
                    catch (Exception)
                    {
                        record.name = db.Contacts.Single(a => a.name.Equals("Test Guy")).name;
                    }
                    record.@new     = (bool)obj["new"];
                    record.email    = (string)obj["email"];
                    record.login_id = (string)obj["login_id"];
                    record.report_access_required = (string)obj["report_access_required"];
                    record.read_only_permission   = (bool)obj["read_only_permission"];
                    List <string> table_permission_required = new List <string>();
                    if (obj["table_permission_required"] != null)
                    {
                        if (obj["table_permission_required"].GetType() == typeof(JValue))
                        {
                            if ((string)obj["table_permission_required"] != "" && (string)obj["table_permission_required"] != null)
                            {
                                table_permission_required.Add((string)obj["table_permission_required"]);
                            }
                        }
                        else
                        {
                            if (((JArray)obj["table_permission_required"]).Count > 0)
                            {
                                String tables = "";
                                for (int i = 0; i < ((JArray)obj["table_permission_required"]).Count; i++)
                                {
                                    tables += (string)((JArray)obj["table_permission_required"])[i];
                                    table_permission_required.Add((string)((JArray)obj["table_permission_required"])[i]);
                                    if ((i + 1) < ((JArray)obj["table_permission_required"]).Count)
                                    {
                                        tables += ", ";
                                    }
                                }
                                record.table_permission_required = tables;
                            }
                        }
                    }

                    db.SubmitChanges();

                    q = q.Where(a => a.project_id == int.Parse(filter) && a.accessusan_req_id == record.accessusan_req_id);

                    return(new PagedData(q.Select(a => new
                        {
                            a.project_id,
                            a.accessusan_req_id,
                            a.@new,
                            a.name,
                            a.email,
                            a.login_id,
                            table_permission_required,
                            //a.table_permission_required,
                            a.report_access_required,
                            a.read_only_permission
                        })));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <AccessUSANReq> list = new List <AccessUSANReq>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        AccessUSANReq record = db.AccessUSANReqs.Single(a => a.accessusan_req_id.Equals((int)objs["accessusan_req_id"]));
                        try
                        {
                            record.name = db.Contacts.Single(a => a.name.Equals((string)objs["name"])).name;
                        }
                        catch (Exception)
                        {
                            record.name = db.Contacts.Single(a => a.name.Equals("Test Guy")).name;
                        }
                        record.@new     = (bool)objs["new"];
                        record.email    = (string)objs["email"];
                        record.login_id = (string)objs["login_id"];
                        record.report_access_required    = (string)objs["report_access_required"];
                        record.read_only_permission      = (bool)objs["read_only_permission"];
                        record.table_permission_required = (string)objs["table_permission_required"];
                        db.SubmitChanges();
                        list.Add(record);
                    }
                    return(new PagedData(list));
                }
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject       obj    = (JObject)blob["rows"];
                    AccessUSANReq record = db.AccessUSANReqs.Single(a => a.accessusan_req_id.Equals((int)obj["accessusan_req_id"]));
                    db.AccessUSANReqs.DeleteOnSubmit(record);
                    db.SubmitChanges();
                    return(new PagedData("AU Assessment Rec Deleted"));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <AccessUSANReq> list = new List <AccessUSANReq>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        JObject       obj    = (JObject)blob["rows"];
                        AccessUSANReq record = db.AccessUSANReqs.Single(a => a.accessusan_req_id.Equals((int)obj["accessusan_req_id"]));
                        db.AccessUSANReqs.DeleteOnSubmit(record);
                        db.SubmitChanges();
                    }
                    return(new PagedData("AU Assessment Recs Deleted"));
                }
            }

            default:
                return(new PagedData("Error: Unsupported Http Request:  " + context.Request.RequestType + " not recognized", false));
            }
        }
Exemple #8
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string readOnly = context.Request.Params.Get("read_only");

            if (isNull(readOnly))
            {
                return(new PagedData("read_only flag is expected"));
            }
            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }

            IQueryable <RoutingRequirement> q = db.RoutingRequirements;

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));
            string  user_name      = context.Request.Params.Get("user_name");
            string  permission     = context.Request.Params.Get("permission");
            string  filter         = context.Request.Params.Get("project_id");
            string  intro          = "The Traffic & Routing page's Change Dnis grid had the following modifications: ";
            string  logBuilder     = "";

            switch (context.Request.RequestType)
            {
            case "GET":
            {
                filter = context.Request.Params.Get("project_id");
                if (!isNull(filter))
                {
                    int id = int.Parse(filter);
                    q = q.Where(a => a.project_id.Equals(id) && a.type.Equals("change"));           //(smm - not needed) && a.remove_from.Length > 1 && a.route_to.Length > 1);
                }

                return(new PagedData(q.Select(a => new { a.routing_requirements_id, a.project_id, a.dnis, a.route_to, a.remove_from, a.platform, a.platform_from, a.description, a.usan_date, a.usan_time, a.dnis_date, a.dnis_time, a.carrier_date, a.carrier_time, a.type })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    RoutingRequirement record = new RoutingRequirement();
                    try
                    {
                        record.project_id = (int)obj["project_id"];
                    }
                    catch (ArgumentException)
                    {
                        record.project_id = int.Parse(filter);
                    }
                    record.dnis        = (String)obj["dnis"];
                    record.remove_from = (String)obj["remove_from"];
                    if (obj["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)obj["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform"])[0];
                        for (int i = 1; i < ((JArray)obj["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description = (String)obj["description"];
                    record.usan_time   = (String)obj["usan_time"];
                    record.usan_date   = (String)obj["usan_date"];
                    record.route_to    = (String)obj["route_to"];
                    if (obj["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)obj["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform_from"])[0];
                        for (int i = 1; i < ((JArray)obj["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }
                    record.dnis_date    = (String)obj["dnis_date"];
                    record.dnis_time    = (String)obj["dnis_time"];
                    record.carrier_date = (String)obj["carrier_date"];
                    record.carrier_time = (String)obj["carrier_time"];
                    record.type         = "change";  //smm

                    db.RoutingRequirements.InsertOnSubmit(record);
                    db.SubmitChanges();
                    logBuilder = "New row added";
                    //if (permission != "PM")
                    //{
                    intro = (intro + logBuilder);
                    intro = intro.Trim();

                    if (intro.LastIndexOf(";") == intro.Length - 1)
                    {
                        intro = intro.Substring(0, intro.Length - 1);
                    }
                    ChangeLog newLog = new ChangeLog();
                    newLog.project_id  = Convert.ToInt32(filter);
                    newLog.time        = DateTime.Now.ToShortTimeString();
                    newLog.date        = DateTime.Now.ToShortDateString();
                    newLog.tab         = "Traffic & Routing";
                    newLog.user_name   = user_name;
                    newLog.description = intro;
                    if ((!db.ChangeLogs.Contains(newLog)) && (logBuilder.Length > 0))
                    {
                        db.ChangeLogs.InsertOnSubmit(newLog);
                        db.SubmitChanges();
                    }
                    //}
                    return(new PagedData(new { record.routing_requirements_id, record.project_id, record.dnis, record.route_to, record.remove_from, record.platform, record.platform_from, record.description, record.usan_date, record.usan_time, record.dnis_date, record.dnis_time, record.carrier_date, record.carrier_time, record.type }));
                }

                JArray        objs = (JArray)blob["rows"];
                List <Object> list = new List <Object>();
                for (int j = 0; j < objs.Count; j++)
                {
                    RoutingRequirement record = new RoutingRequirement();
                    try
                    {
                        record.project_id = (int)objs[j]["project_id"];
                    }
                    catch (ArgumentException)
                    {
                        record.project_id = int.Parse(filter);
                    }
                    record.dnis        = (String)objs[j]["dnis"];
                    record.remove_from = (String)objs[j]["remove_from"];
                    if (objs[j]["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)objs[j]["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description = (String)objs[j]["description"];
                    record.usan_date   = (String)objs[j]["usan_date"];
                    record.usan_time   = (String)objs[j]["usan_time"];
                    record.route_to    = (String)objs[j]["route_to"];
                    if (objs[j]["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)objs[j]["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform_from"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }
                    record.dnis_date    = (String)objs[j]["dnis_date"];
                    record.dnis_time    = (String)objs[j]["dnis_time"];
                    record.carrier_date = (String)objs[j]["carrier_date"];
                    record.carrier_time = (String)objs[j]["carrier_time"];
                    record.type         = "change";  //smm

                    db.RoutingRequirements.InsertOnSubmit(record);
                    db.SubmitChanges();

                    list.Add(new { record.routing_requirements_id, record.project_id, record.dnis, record.route_to, record.remove_from, record.platform, record.platform_from, record.description, record.usan_date, record.usan_time, record.dnis_date, record.dnis_time, record.carrier_date, record.carrier_time, record.type });
                }

                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    RoutingRequirement record = db.RoutingRequirements.Single(a => a.routing_requirements_id.Equals((int)obj["routing_requirements_id"]));
                    if (record.dnis != null && record.dnis.Length > 0)
                    {
                        intro += "Row New Dnis: \"" + record.dnis + "\": ";
                    }
                    else
                    {
                        intro += "Row New Dnis: \"(empty DNIS)\": ";
                    }
                    if (record.dnis != (String)obj["dnis"])
                    {
                        logBuilder += "New Dnis changed from \"" + record.dnis + "\" -> \"" + (String)obj["dnis"] + "\"; ";
                    }
                    record.dnis = (String)obj["dnis"];
                    if (obj["remove_from"] != null)
                    {
                        if (record.remove_from != (String)obj["remove_from"])
                        {
                            logBuilder += "App To Be Removed From changed from \"" + record.remove_from + "\" -> \"" + (String)obj["remove_from"] + "\"; ";
                        }
                        record.remove_from = (String)obj["remove_from"];
                    }

                    //record.platform = (string)obj["platform"];

                    if (obj["platform"].GetType() == typeof(JValue))
                    {
                        if (record.platform != (String)obj["platform"])
                        {
                            logBuilder += "Platform changed from \"" + record.platform + "\" -> \"" + (String)obj["platform"] + "\"; ";
                        }
                        record.platform = (String)obj["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform"])[0];
                        for (int i = 1; i < ((JArray)obj["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform"])[i];
                        }
                        if (record.platform != platforms)
                        {
                            logBuilder += "Platform changed from \"" + record.platform + "\" -> \"" + platforms + "\"; ";
                        }
                        record.platform = platforms;
                    }
                    if (record.description != (String)obj["description"])
                    {
                        logBuilder += "Description changed from \"" + record.description + "\" -> \"" + (String)obj["description"] + "\"; ";
                    }
                    record.description = (String)obj["description"];
                    if (record.usan_time != (String)obj["usan_time"])
                    {
                        logBuilder += "USAN Prod Routing Time changed from \"" + record.usan_time + "\" -> \"" + (String)obj["usan_time"] + "\"; ";
                    }
                    record.usan_time = (String)obj["usan_time"];
                    if (record.usan_date != (String)obj["usan_date"])
                    {
                        logBuilder += "USAN Prod Routing Date changed from \"" + record.usan_date + "\" -> \"" + (String)obj["usan_date"] + "\"; ";
                    }
                    record.usan_date = (String)obj["usan_date"];
                    if (record.route_to != (String)obj["route_to"])
                    {
                        logBuilder += "App To Be Routed To changed from \"" + record.route_to + "\" -> \"" + (String)obj["route_to"] + "\"; ";
                    }
                    record.route_to = (String)obj["route_to"];
                    if (obj["platform_from"].GetType() == typeof(JValue))
                    {
                        if (record.platform_from != (String)obj["platform_from"])
                        {
                            logBuilder += "Platform From changed from \"" + record.platform_from + "\" -> \"" + (String)obj["platform_from"] + "\"; ";
                        }
                        record.platform_from = (String)obj["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)obj["platform_from"])[0];
                        for (int i = 1; i < ((JArray)obj["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)obj["platform_from"])[i];
                        }
                        if (record.platform_from != platforms)
                        {
                            logBuilder += "Platform From changed from \"" + record.platform_from + "\" -> \"" + platforms + "\"; ";
                        }
                        record.platform_from = platforms;
                    }
                    if (record.dnis_date != (String)obj["dnis_date"])
                    {
                        logBuilder += "DNIS Table Prod Load Date changed from \"" + record.dnis_date + "\" -> \"" + (String)obj["dnis_date"] + "\"; ";
                    }
                    record.dnis_date = (String)obj["dnis_date"];
                    if (record.dnis_time != (String)obj["dnis_time"])
                    {
                        logBuilder += "DNIS Table Prod Load Time changed from \"" + record.dnis_time + "\" -> \"" + (String)obj["dnis_time"] + "\"; ";
                    }
                    record.dnis_time = (String)obj["dnis_time"];
                    if (record.carrier_date != (String)obj["carrier_date"])
                    {
                        logBuilder += "Carrier Prod Routing Date changed from \"" + record.carrier_date + "\" -> \"" + (String)obj["carrier_date"] + "\"; ";
                    }
                    record.carrier_date = (String)obj["carrier_date"];
                    if (record.carrier_time != (String)obj["carrier_time"])
                    {
                        logBuilder += "Carrier Prod Routing Time changed from \"" + record.carrier_time + "\" -> \"" + (String)obj["carrier_time"] + "\"; ";
                    }
                    record.carrier_time = (String)obj["carrier_time"];
                    record.type         = "change";  //smm

                    db.SubmitChanges();
                    //if (permission != "PM")
                    //{
                    intro = (intro + logBuilder);
                    intro = intro.Trim();

                    if (intro.LastIndexOf(";") == intro.Length - 1)
                    {
                        intro = intro.Substring(0, intro.Length - 1);
                    }
                    ChangeLog newLog = new ChangeLog();
                    newLog.project_id  = Convert.ToInt32(filter);
                    newLog.time        = DateTime.Now.ToShortTimeString();
                    newLog.date        = DateTime.Now.ToShortDateString();
                    newLog.tab         = "Traffic & Routing";
                    newLog.user_name   = user_name;
                    newLog.description = intro;
                    if ((!db.ChangeLogs.Contains(newLog)) && (logBuilder.Length > 0))
                    {
                        db.ChangeLogs.InsertOnSubmit(newLog);
                        db.SubmitChanges();
                    }
                    //}
                    return(new PagedData(new { record.routing_requirements_id, record.project_id, record.dnis, record.route_to, record.remove_from, record.platform, record.platform_from, record.description, record.usan_date, record.usan_time, record.dnis_date, record.dnis_time, record.carrier_date, record.carrier_time, record.type }));
                }

                JArray        objs = (JArray)blob["rows"];
                List <Object> list = new List <Object>();
                for (int j = 0; j < objs.Count; j++)
                {
                    RoutingRequirement record = db.RoutingRequirements.Single(a => a.routing_requirements_id.Equals((int)objs[j]["routing_requirements_id"]));
                    record.dnis        = (String)objs[j]["dnis"];
                    record.remove_from = (String)objs[j]["remove_from"];
                    if (objs[j]["platform"].GetType() == typeof(JValue))
                    {
                        record.platform = (String)objs[j]["platform"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform"])[i];
                        }
                        record.platform = platforms;
                    }
                    record.description = (String)objs[j]["description"];
                    record.usan_date   = (String)objs[j]["usan_date"];
                    record.usan_time   = (String)objs[j]["usan_time"];
                    record.route_to    = (String)objs[j]["route_to"];
                    if (objs[j]["platform_from"].GetType() == typeof(JValue))
                    {
                        record.platform_from = (String)objs[j]["platform_from"];
                    }
                    else
                    {
                        string platforms = (String)((JArray)objs[j]["platform_from"])[0];
                        for (int i = 1; i < ((JArray)objs[j]["platform_from"]).Count; i++)
                        {
                            platforms = platforms + ", " + (String)((JArray)objs[j]["platform_from"])[i];
                        }
                        record.platform_from = platforms;
                    }
                    record.dnis_date    = (String)objs[j]["dnis_date"];
                    record.dnis_time    = (String)objs[j]["dnis_time"];
                    record.carrier_date = (String)objs[j]["carrier_date"];
                    record.carrier_time = (String)objs[j]["carrier_time"];
                    record.type         = "change";  //smm

                    list.Add(new { record.routing_requirements_id, record.project_id, record.dnis, record.route_to, record.remove_from, record.platform, record.platform_from, record.description, record.usan_date, record.usan_time, record.dnis_date, record.dnis_time, record.carrier_date, record.carrier_time, record.type });
                }

                db.SubmitChanges();

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    RoutingRequirement record = db.RoutingRequirements.Single(a => a.routing_requirements_id.Equals((int)obj["routing_requirements_id"]));
                    logBuilder += "Row deleted: New Dnis: \"" + record.dnis + "\"; APP To Be Routed To: \"" + record.route_to + "\"; Platform: \"" + record.platform + "\"; Description: \"" +
                                  record.description + "\"; App To Be Removed From: \"" + record.remove_from + "\"; Platform From: \"" + record.platform_from + "\"; USAN Prod Routing Date: \"" + record.usan_date + "\"; USAN Prod Routing Time: \"" + record.usan_time + "\"; DNIS Table Prod Load Date: \"" + record.dnis_date +
                                  "\"; DNIS Table Prod Load Time: \"" + record.dnis_time + "\"; Carrier Prod Routing Date: \"" + record.carrier_date + "\"; Carrier Prod Routing Time: \"" + record.carrier_time + "\"";
                    db.RoutingRequirements.DeleteOnSubmit(record);

                    db.SubmitChanges();
                    //if (permission != "PM")
                    //{
                    intro = (intro + logBuilder);
                    intro = intro.Trim();

                    if (intro.LastIndexOf(";") == intro.Length - 1)
                    {
                        intro = intro.Substring(0, intro.Length - 1);
                    }
                    ChangeLog newLog = new ChangeLog();
                    newLog.project_id  = Convert.ToInt32(filter);
                    newLog.time        = DateTime.Now.ToShortTimeString();
                    newLog.date        = DateTime.Now.ToShortDateString();
                    newLog.tab         = "Traffic & Routing";
                    newLog.user_name   = user_name;
                    newLog.description = intro;
                    if ((!db.ChangeLogs.Contains(newLog)) && (logBuilder.Length > 0))
                    {
                        db.ChangeLogs.InsertOnSubmit(newLog);
                        db.SubmitChanges();
                    }
                    //}
                    return(new PagedData("dnis deleted"));
                }

                JArray objs = (JArray)blob["rows"];
                for (int j = 0; j < objs.Count; j++)
                {
                    RoutingRequirement record = db.RoutingRequirements.Single(a => a.routing_requirements_id.Equals((int)objs[j]["routing_requirements_id"]));
                    db.RoutingRequirements.DeleteOnSubmit(record);
                }

                db.SubmitChanges();

                return(new PagedData("dnises deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            if (context.Request.Params.Count == 0)
            {
                return(new PagedData("Can't call AddApplications.ashx without parameters"));
            }

            Application app           = new Application();
            int         existingAppID = -1;

            for (int i = 0; i < context.Request.Params.Count; i++)
            {
                var currentParam     = context.Request.Params.GetKey(i).Trim();
                var currentParamData = context.Request.Params.Get(i).Trim();

                switch (currentParam)
                {
                case "application":
                {
                    app.base_name = currentParamData;
                    app.name      = app.base_name + ".APP";
                    break;
                }

                case "product":
                {
                    app.Product = currentParamData;
                    break;
                }

                case "division":
                {
                    app.Division = currentParamData;
                    break;
                }

                case "platform":
                {
                    app.Platform = currentParamData;
                    break;
                }

                case "serviceid":
                {
                    app.ServiceID = currentParamData;
                    break;
                }

                case "applications_id":
                {
                    if (currentParamData != "add")
                    {
                        existingAppID = Convert.ToInt32(currentParamData);
                    }
                    break;
                }

                default:
                    break;
                }
            }

            if (existingAppID < 0)
            {
                db.Applications.InsertOnSubmit(app);
            }
            else
            {
                if (db.Applications.Count(a => a.applications_id.Equals(existingAppID)) > 0)
                {
                    Application existingApp = db.Applications.First(a => a.applications_id.Equals(existingAppID));
                    existingApp.base_name = app.base_name;
                    existingApp.name      = app.name;
                    existingApp.Product   = app.Product;
                    existingApp.Division  = app.Division;
                    existingApp.Platform  = app.Platform;
                    existingApp.ServiceID = app.ServiceID;
                }
                else
                {
                    return(new PagedData("Could not find the existing app to edit!"));
                }
            }

            db.SubmitChanges();

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

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var     jsonSerializer = new JsonSerializer();
            JObject blob           = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));


            switch (context.Request.RequestType)
            {
            case "GET":
            {
                //string user_name = context.Request.Params.Get("user_name");
                //q = q.Where(a => a.user_name.Equals(user_name));
                return(new PagedData(q.Select(a => new { a.deliverable_id, a.deliverable_text, a.user_name, a.business_unit, a.category })));
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Deliverable record = new Deliverable();
                    record.deliverable_text = (string)obj["deliverable_text"];
                    record.user_name        = (string)obj["user_name"];
                    record.business_unit    = (string)obj["business_unit"];
                    record.category         = (string)obj["category"];

                    db.Deliverables.InsertOnSubmit(record);
                    db.SubmitChanges();

                    return(new PagedData(record));         //JsonConvert.SerializeObject(newApp));
                }

                JArray             objs = (JArray)blob["rows"];
                List <Deliverable> list = new List <Deliverable>();
                for (int j = 0; j < objs.Count; j++)
                {
                    Deliverable record = new Deliverable();
                    record.deliverable_text = (string)objs[j]["deliverable_text"];
                    record.user_name        = (string)objs[j]["user_name"];
                    record.business_unit    = (string)objs[j]["business_unit"];
                    record.category         = (string)objs[j]["category"];

                    db.Deliverables.InsertOnSubmit(record);
                    list.Add(record);
                }

                db.SubmitChanges();

                return(new PagedData(list));
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Deliverable record = db.Deliverables.Single(a => a.deliverable_id.Equals((int)obj["deliverable_id"]));
                    record.deliverable_text = (string)obj["deliverable_text"];
                    if (obj["user_name"] != null)
                    {
                        record.user_name = (string)obj["user_name"];
                    }
                    record.business_unit = (string)obj["business_unit"];
                    record.category      = (string)obj["category"];

                    db.SubmitChanges();

                    return(new PagedData(record));         //JsonConvert.SerializeObject(newApp));
                }

                JArray             objs = (JArray)blob["rows"];
                List <Deliverable> list = new List <Deliverable>();
                for (int j = 0; j < objs.Count; j++)
                {
                    Deliverable record = db.Deliverables.Single(a => a.deliverable_id.Equals((int)objs[j]["deliverable_id"]));
                    record.deliverable_text = (string)objs[j]["deliverable_text"];
                    if (objs[j]["user_name"] != null)
                    {
                        record.user_name = (string)objs[j]["user_name"];
                    }
                    record.business_unit = (string)objs[j]["business_unit"];
                    record.category      = (string)objs[j]["category"];

                    db.SubmitChanges();
                    list.Add(record);
                }

                return(new PagedData(list));
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject obj = (JObject)blob["rows"];

                    Deliverable record = db.Deliverables.Single(a => a.deliverable_id.Equals((int)obj["deliverable_id"]));
                    db.Deliverables.DeleteOnSubmit(record);

                    db.SubmitChanges();

                    return(new PagedData("good"));
                }

                JArray objs = (JArray)blob["rows"];
                for (int j = 0; j < objs.Count; j++)
                {
                    Deliverable record = db.Deliverables.Single(a => a.deliverable_id.Equals((int)objs[j]["deliverable_id"]));
                    db.Deliverables.DeleteOnSubmit(record);
                }

                db.SubmitChanges();

                return(new PagedData("deleted"));
            }

            default:
                return(new PagedData("Unsupported Http Request:  " + context.Request.RequestType + " not recognized"));
            }
        }
Exemple #11
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            IQueryable <HardwareRequirement> q = db.HardwareRequirements;

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

            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);
            var     jsonSerializer        = new JsonSerializer();
            JObject blob     = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));
            string  readOnly = context.Request.Params.Get("read_only");

            if (readOnly == "true" && context.Request.RequestType != "GET")
            {
                return(new PagedData("Read Only"));
            }
            switch (context.Request.RequestType)
            {
            case "GET":
            {
                if (!isNull(filter))
                {
                    q = q.Where(a => a.project_id == int.Parse(filter));

                    return(new PagedData(q.Select(a => new
                        {
                            a.hardware_req_id,
                            a.description,
                            a.cost_per_item,
                            a.quantity,
                            a.total_item_cost,
                            a.target_delivery,
                            a.target_order_date,
                            a.actual_delivery_date,
                            a.actual_order_date,
                            a.requirement_type,
                            a.number_of_sites
                        })));
                }
                else
                {
                    return(new PagedData("GetHardwareRequirements expects a project_id"));
                }
            }

            case "POST":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject             obj    = (JObject)blob["rows"];
                    HardwareRequirement record = new HardwareRequirement();

                    record.project_id           = int.Parse(filter);
                    record.description          = "";
                    record.cost_per_item        = "";
                    record.quantity             = 0;
                    record.total_item_cost      = "";
                    record.target_order_date    = "";
                    record.target_delivery      = "";
                    record.actual_delivery_date = "";
                    record.actual_order_date    = "";
                    record.number_of_sites      = 0;
                    try
                    {
                        record.requirement_type = (string)obj["requirement_type"];
                    }
                    catch (Exception)
                    {
                        record.requirement_type = "One Time Charges";
                    }
                    db.HardwareRequirements.InsertOnSubmit(record);
                    db.SubmitChanges();

                    return(new PagedData(record));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <HardwareRequirement> list = new List <HardwareRequirement>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        HardwareRequirement record = new HardwareRequirement();

                        record.project_id           = int.Parse(filter);
                        record.description          = "";
                        record.cost_per_item        = "";
                        record.quantity             = 0;
                        record.total_item_cost      = "";
                        record.target_order_date    = "";
                        record.target_delivery      = "";
                        record.actual_delivery_date = "";
                        record.actual_order_date    = "";
                        try
                        {
                            record.requirement_type = (string)objs["requirement_type"];
                        }
                        catch (Exception)
                        {
                            record.requirement_type = "One Time Charges";
                        }
                        record.number_of_sites = 0;

                        db.HardwareRequirements.InsertOnSubmit(record);
                        db.SubmitChanges();
                        list.Add(record);
                    }
                    return(new PagedData(list));
                }
            }

            case "PUT":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject             obj    = (JObject)blob["rows"];
                    HardwareRequirement record = db.HardwareRequirements.Single(a => a.hardware_req_id.Equals((int)obj["hardware_req_id"]));
                    record.description     = (string)obj["description"];
                    record.cost_per_item   = obj["cost_per_item"] == null ? "0" : (string)obj["cost_per_item"];
                    record.quantity        = obj["quantity"] == null ? 0 : (int)obj["quantity"];
                    record.number_of_sites = obj["number_of_sites"] == null ? 0 : (int)obj["number_of_sites"];
                    try
                    {
                        record.total_item_cost = "$" + (record.quantity * double.Parse(record.cost_per_item) * record.number_of_sites);
                    }
                    catch (Exception)
                    {
                        record.total_item_cost = "";
                    }
                    record.target_order_date    = obj["target_order_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["target_order_date"]) : ((string)obj["target_order_date"] == null ? "" : (string)obj["target_order_date"]);
                    record.target_delivery      = obj["target_delivery"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["target_delivery"]) : ((string)obj["target_delivery"] == null ? "" : (string)obj["target_delivery"]);
                    record.actual_delivery_date = obj["actual_delivery_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["actual_delivery_date"]) : ((string)obj["actual_delivery_date"] == null ? "" : (string)obj["actual_delivery_date"]);
                    record.actual_order_date    = obj["actual_order_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)obj["actual_order_date"]) : ((string)obj["actual_order_date"] == null ? "" : (string)obj["actual_order_date"]);
                    try
                    {
                        record.requirement_type = (string)obj["requirement_type"];
                    }
                    catch (Exception)
                    {
                        record.requirement_type = "One Time Charges";
                    }
                    db.SubmitChanges();
                    return(new PagedData(record));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <HardwareRequirement> list = new List <HardwareRequirement>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        HardwareRequirement record = db.HardwareRequirements.Single(a => a.hardware_req_id.Equals((int)objs["hardware_req_id"]));
                        record.description     = (string)objs["description"];
                        record.cost_per_item   = objs["cost_per_item"] == null ? "0" : (string)objs["cost_per_item"];
                        record.quantity        = objs["quantity"] == null ? 0 : (int)objs["quantity"];
                        record.number_of_sites = objs["number_of_sites"] == null ? 0 : (int)objs["number_of_sites"];
                        try
                        {
                            record.total_item_cost = "$" + (record.quantity * double.Parse(record.cost_per_item) * record.number_of_sites);
                        }
                        catch (Exception)
                        {
                            record.total_item_cost = "";
                        }
                        record.target_order_date    = objs["target_order_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["target_order_date"]) : ((string)objs["target_order_date"] == null ? "" : (string)objs["target_order_date"]);
                        record.target_delivery      = objs["target_delivery"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["target_delivery"]) : ((string)objs["target_delivery"] == null ? "" : (string)objs["target_delivery"]);
                        record.actual_delivery_date = objs["actual_delivery_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["actual_delivery_date"]) : ((string)objs["actual_delivery_date"] == null ? "" : (string)objs["actual_delivery_date"]);
                        record.actual_order_date    = objs["actual_order_date"].ToString().Contains("T00:00:00") ? convertToProperDate((string)objs["actual_order_date"]) : ((string)objs["actual_order_date"] == null ? "" : (string)objs["actual_order_date"]);
                        try
                        {
                            record.requirement_type = (string)objs["requirement_type"];
                        }
                        catch (Exception)
                        {
                            record.requirement_type = "One Time Charges";
                        }
                        db.SubmitChanges();
                    }
                    return(new PagedData(list));
                }
            }

            case "DELETE":
            {
                if (blob["rows"].GetType() == typeof(JObject))
                {
                    JObject             obj    = (JObject)blob["rows"];
                    HardwareRequirement record = db.HardwareRequirements.Single(a => a.hardware_req_id.Equals((int)obj["hardware_req_id"]));
                    db.HardwareRequirements.DeleteOnSubmit(record);
                    db.SubmitChanges();
                    return(new PagedData("Hardware Rec Deleted"));
                }
                else
                {
                    JArray objs = (JArray)blob["rows"];
                    List <HardwareRequirement> list = new List <HardwareRequirement>();
                    for (int j = 0; j < objs.Count; j++)
                    {
                        JObject             obj    = (JObject)blob["rows"];
                        HardwareRequirement record = db.HardwareRequirements.Single(a => a.hardware_req_id.Equals((int)obj["hardware_req_id"]));
                        db.HardwareRequirements.DeleteOnSubmit(record);
                        db.SubmitChanges();
                    }
                    return(new PagedData("Hardware Recs Deleted"));
                }
            }

            default:
                return(new PagedData("Error: Unsupported Http Request:  " + context.Request.RequestType + " not recognized", false));
            }
        }
Exemple #12
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            string idPassed = "";

            if (context.Request.Params.Count == 0)
            {
                return(new PagedData("Can't call AddScraper.ashx without parameters"));
            }

            if (context.Request.Params.Get("name") == null)
            {
                return(new PagedData("Name is null"));
            }
            if (context.Request.Params.Get("edit") != "true")
            {
                Scraper scraper = new Scraper();
                scraper.name = context.Request.Params.Get("name");
                if (context.Request.Params.Get("type") != null)
                {
                    if (db.ScraperTypes.Count(a => a.type.Equals(context.Request.Params.Get("type"))) == 1)
                    {
                        scraper.ScraperType = db.ScraperTypes.Single(a => a.type.Equals(context.Request.Params.Get("type")));
                    }
                    else
                    {
                        scraper.ScraperType = null;
                    }
                }
                else
                {
                    scraper.ScraperType = null;
                }

                db.Scrapers.InsertOnSubmit(scraper);
                db.SubmitChanges();

                return(new PagedData("scraper added"));
            }
            else
            {
                if (context.Request.Params.Get("id") != null && context.Request.Params.Get("id") != "")
                {
                    idPassed = context.Request.Params.Get("id");
                }
                else
                {
                    return(new PagedData("ID is null", false));
                }

                if (db.Scrapers.Count(a => a.scraper_id.Equals(idPassed)) == 1)
                {
                    Scraper existingScraper = db.Scrapers.Single(a => a.scraper_id.Equals(idPassed));
                    existingScraper.name = context.Request.Params.Get("name");
                    if (context.Request.Params.Get("type") != null)
                    {
                        if (db.ScraperTypes.Count(a => a.type.Equals(context.Request.Params.Get("type"))) == 1)
                        {
                            existingScraper.ScraperType = db.ScraperTypes.Single(a => a.type.Equals(context.Request.Params.Get("type")));
                        }
                        else
                        {
                            existingScraper.ScraperType = null;
                        }
                    }
                    else
                    {
                        existingScraper.ScraperType = null;
                    }

                    db.SubmitChanges();
                    return(new PagedData("scraper edited"));
                }
                else
                {
                    return(new PagedData("Error: scraper ID passed either does not exist or has multiple matches (" + db.Scrapers.Count(a => a.scraper_id.Equals(idPassed)) + ")...Contact Cookbook Admin", false));
                }
            }
        }
Exemple #13
0
        public override PagedData ProcessRequest(HttpContext context, CookDBDataContext db)
        {
            System.IO.StreamReader reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding);

            var jsonSerializer = new JsonSerializer();
            //JObject blob = (JObject)jsonSerializer.Deserialize(new JsonTextReader(new StringReader(reader.ReadToEnd())));
            String incomingProjectName = (string)(reader.ReadToEnd());

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

            if (!isNull(filter))
            {
                if (isNull(install_type))
                {
                    return(new PagedData("no install type submitted"));
                }
                else
                {
                    switch (install_type)
                    {
                    case ("uat"):
                    {
                        if (db.ProjectRequirements.Count(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("uat")) > 0)
                        {
                            var wiping = db.ProjectRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("uat"));
                            db.ProjectRequirements.DeleteAllOnSubmit(wiping);
                            db.SubmitChanges();
                            comment += "[Project ID: " + int.Parse(filter) + " type:" + install_type + " cleared]";
                        }
                        break;
                    }

                    case ("prod"):
                    {
                        if (db.ProjectRequirements.Count(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("prod")) > 0)
                        {
                            var wiping = db.ProjectRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("prod"));
                            db.ProjectRequirements.DeleteAllOnSubmit(wiping);
                            db.SubmitChanges();
                            comment += "[Project ID: " + int.Parse(filter) + " type:" + install_type + " cleared]";
                        }
                        break;
                    }

                    case ("soak"):
                    {
                        if (db.ProjectRequirements.Count(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("soak")) > 0)
                        {
                            var wiping = db.ProjectRequirements.Where(a => a.project_id.Equals(int.Parse(filter)) && a.type.ToLower().Equals("soak"));
                            db.ProjectRequirements.DeleteAllOnSubmit(wiping);
                            db.SubmitChanges();
                            comment += "[Project ID: " + int.Parse(filter) + " type:" + install_type + " cleared]";
                        }
                        break;
                    }

                    default:
                        return(new PagedData("no valid install type submitted"));
                    }
                }

                try
                {
                    //application
                    if (db.ApplicationReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.ApplicationReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].app_file != null && allTheReqs[i].app_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].app_file;
                                newReq.name            = allTheReqs[i].app_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Application"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].rpt_file != null && allTheReqs[i].rpt_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].rpt_file;
                                newReq.name            = allTheReqs[i].rpt_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Application"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].prm_file != null && allTheReqs[i].prm_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].prm_file;
                                newReq.name            = allTheReqs[i].prm_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Application"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].prm_instructions != null && allTheReqs[i].prm_instructions != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].prm_instructions;
                                newReq.name            = allTheReqs[i].prm_instructions;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Application"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }

                    //table
                    if (db.TableReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.TableReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].xls_csv_file != null && allTheReqs[i].xls_csv_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].xls_csv_file;
                                newReq.name            = allTheReqs[i].xls_csv_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Table"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].def_file != null && allTheReqs[i].def_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].def_file;
                                newReq.name            = allTheReqs[i].def_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Table"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].etm_file != null && allTheReqs[i].etm_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].etm_file;
                                newReq.name            = allTheReqs[i].etm_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Table"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }

                    //routing
                    if (db.RequirementsTabRoutingRequirements.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.RequirementsTabRoutingRequirements.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].description != null && allTheReqs[i].description != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].description;
                                newReq.name            = allTheReqs[i].description;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Routing"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }

                    //scraper
                    if (db.ScraperReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.ScraperReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].exe_file != null && allTheReqs[i].exe_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].exe_file;
                                newReq.name            = allTheReqs[i].exe_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Scraper"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].pdb_file != null && allTheReqs[i].pdb_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].pdb_file;
                                newReq.name            = allTheReqs[i].pdb_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Scraper"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //engine
                    if (db.EngineReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.EngineReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].exe_file != null && allTheReqs[i].exe_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].exe_file;
                                newReq.name            = allTheReqs[i].exe_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Engine"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].pdb_file != null && allTheReqs[i].pdb_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].pdb_file;
                                newReq.name            = allTheReqs[i].pdb_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Engine"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //manager
                    if (db.ManagerReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.ManagerReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].exe_file != null && allTheReqs[i].exe_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].exe_file;
                                newReq.name            = allTheReqs[i].exe_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Manager"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].pdb_file != null && allTheReqs[i].pdb_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].pdb_file;
                                newReq.name            = allTheReqs[i].pdb_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Manager"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //grammar
                    if (db.GrammarReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.GrammarReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].filename != null && allTheReqs[i].filename != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].filename;
                                newReq.name            = allTheReqs[i].filename;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Grammar"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //vxml
                    if (db.VXMLReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.VXMLReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].description != null && allTheReqs[i].description != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].description;
                                newReq.name            = allTheReqs[i].description;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("VXML"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //backoffice DB
                    if (db.BackofficeDBReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.BackofficeDBReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].sql_file != null && allTheReqs[i].sql_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].sql_file;
                                newReq.name            = allTheReqs[i].sql_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Backoffice DB"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //backoffice process
                    if (db.BackofficeProcessReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.BackofficeProcessReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].exe_file != null && allTheReqs[i].exe_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].exe_file;
                                newReq.name            = allTheReqs[i].exe_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Backoffice Process"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //backoffice webservice
                    if (db.BackofficeWebserviceReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.BackofficeWebserviceReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].war_file != null && allTheReqs[i].war_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].war_file;
                                newReq.name            = allTheReqs[i].war_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Backoffice Webservice"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].tar_file != null && allTheReqs[i].tar_file != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].tar_file;
                                newReq.name            = allTheReqs[i].tar_file;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Backoffice Webservice"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //configuration file
                    if (db.ConfigFileReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.ConfigFileReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].filename != null && allTheReqs[i].filename != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].filename;
                                newReq.name            = allTheReqs[i].filename;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Configuration File"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].instructions != null && allTheReqs[i].instructions != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].instructions;
                                newReq.name            = allTheReqs[i].instructions;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Configuration File"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //fax form
                    if (db.FaxFormReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.FaxFormReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].filename != null && allTheReqs[i].filename != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].filename;
                                newReq.name            = allTheReqs[i].filename;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Fax Form"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].instructions != null && allTheReqs[i].instructions != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].instructions;
                                newReq.name            = allTheReqs[i].instructions;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Fax Form"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //file xfer upload/download
                    if (db.FileXferReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.FileXferReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].name != null && allTheReqs[i].name != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].name;
                                newReq.name            = allTheReqs[i].name;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("File Xfer"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //tts functionality
                    if (db.TTSFunctionalityReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.TTSFunctionalityReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].call_volume != null && allTheReqs[i].call_volume != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].call_volume;
                                newReq.name            = allTheReqs[i].call_volume;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("TTS Functionality"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //tnt functionality
                    if (db.TNTFunctionalityReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.TNTFunctionalityReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].call_volume != null && allTheReqs[i].call_volume != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].call_volume;
                                newReq.name            = allTheReqs[i].call_volume;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("TNT Functionality"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //speech recognition
                    if (db.SpeechRecognitionReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.SpeechRecognitionReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].call_volume != null && allTheReqs[i].call_volume != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].call_volume;
                                newReq.name            = allTheReqs[i].call_volume;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Speech Recognition"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //uui
                    if (db.UUIReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.UUIReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].call_volume != null && allTheReqs[i].call_volume != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].call_volume;
                                newReq.name            = allTheReqs[i].call_volume;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("UUI"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //service id
                    if (db.ServiceIDReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.ServiceIDReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].product != null && allTheReqs[i].product != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].product;
                                newReq.name            = allTheReqs[i].product;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Service ID"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                            if (allTheReqs[i].service_id != null && allTheReqs[i].service_id != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].service_id;
                                newReq.name            = allTheReqs[i].service_id;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Service ID"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                    //other
                    if (db.OtherReqs.Count(a => a.project_id.Equals(int.Parse(filter))) > 0)
                    {
                        var allTheReqs = db.OtherReqs.Where(a => a.project_id.Equals(int.Parse(filter))).ToList();
                        for (int i = 0; i < allTheReqs.Count(); i++)
                        {
                            if (allTheReqs[i].misc != null && allTheReqs[i].misc != "")
                            {
                                ProjectRequirement newReq = new ProjectRequirement();
                                newReq.type            = install_type;
                                newReq.project_id      = int.Parse(filter);
                                newReq.filename        = allTheReqs[i].misc;
                                newReq.name            = allTheReqs[i].misc;
                                newReq.RequirementType = db.RequirementTypes.Single(a => a.type.Equals("Other"));
                                db.ProjectRequirements.InsertOnSubmit(newReq);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    return(new PagedData("Error: please show cookbook admin this screen: " + e.Message + "|" + e.Source + "|" + e.StackTrace + "|" + e.InnerException));
                }

                db.SubmitChanges();

                return(new PagedData("success! " + comment));
            }
            return(new PagedData("no proj id submitted"));
        }