Esempio n. 1
0
        public ActionResult Detail(SGP.BLL.Models.RFQDetail rf)
        {
            int RFQID = 0;
            if (Request.QueryString["RFQID"] != null)
            {
                RFQID = Int32.Parse(Request.QueryString["RFQID"]);
            }
            if (SGP.BLL.Models.RFQManager.GetDetail(RFQID).Count > 0)
            {

                rf = SGP.BLL.Models.RFQManager.GetDetail(RFQID)[0];
            }

            if (RFQID > 0)
            {
                SGP.BLL.WF.WFTemplate wf = new WFTemplate(1, RFQID);
                if (wf.CurrentActivity != null)
                {
                    ViewData["CurrWFID"] = wf.CurrentActivity.ID;
                }
                ViewData["LastWFID"] = wf.LastActivity.ID;

            }
            return View(rf);
        }
Esempio n. 2
0
        /// <summary>
        /// Assign RFQ VVI to Supplier
        /// </summary>
        /// <returns></returns>
        /// 
        public ActionResult AssignSupplier()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string postData = Request["postData"];
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;
            Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;
            string dataId = Convert.ToString(jsonData["dataId"]);
            string operation = Convert.ToString(jsonData["operation"]);
            string suppliercode = Convert.ToString(jsonData["SupplierCode"]);
            List<FieldCategory> lfc = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);
            Int32.TryParse(dataId, out id);

            using (TScope ts = new TScope())
            {
                try
                {

                    VVIQuotationDetail dm = new VVIQuotationDetail(lfc, data);

                    if (id > 0)
                    {

                        dm.AssignVVIData(id, suppliercode, sysMsg);
                    }
                    else
                    {
                        sysMsg.isPass = false;
                        sysMsg.Messages.Add("Error", "Please select a RFQ ");
                    }

                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    sysMsg.isPass = false;
                    sysMsg.Messages.Add("Error", ex.Message);
                }
            }
            string html = "";
            string wfStatus = "";

            VVIQuotationDetail b2Detail = new VVIQuotationDetail();
            // List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_VVI);
            b2Detail.FillCategoryData(lfc, id);
            WFTemplate wfTemplate = new WFTemplate("VVIWF", id);
            html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
            wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";

            var returnData = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                wfStatus = wfStatus
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 3
0
 public UserChangedEvent(int RFQID)
 {
     return;
     _entityId = RFQID;
     if (_entityId > 0)
     {
         WFTemplate wf = new WFTemplate(1, _entityId);
         _activity = wf.CurrentActivity;
     }
 }
Esempio n. 4
0
        public static void CheckField(WFTemplate template, List<WFActivityField> listFields, SystemMessages sysMsg, WFActivity activity)
        {
            if (sysMsg == null)
            {
                sysMsg = CreateMessages();
            }

            foreach (WFActivityField field in listFields)
            {
                if (field.IsRequired)
                {
                    if (String.IsNullOrEmpty(field.SubDataType))
                    {
                        bool isEmpty = true;
                        if (template.MasterData.Table.Columns.Contains(field.FieldName))
                        {
                            string fieldValue = Convert.ToString(template.MasterData[field.FieldName]).Trim();
                            isEmpty = FieldIsEmpty(field, fieldValue);
                        }
                        if (isEmpty)
                        {
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add(String.Format("{0} - Validation", template.MasterData[activity.Template.MessageField])  , String.Format("\"{0}\" is required.", field.DisplayName));
                        }
                    }
                    else
                    {
                        bool isEmpty = true;
                        string tableName = field.SubDataType.ToUpper();
                        if (template.SubData.ContainsKey(tableName))
                        {
                            DataTable subDt = template.SubData[tableName];
                            if (subDt.Rows.Count > 0)
                            {
                                isEmpty = false;
                                for (int i = 0; i < subDt.Rows.Count; i++)
                                {
                                    string fieldValue = Convert.ToString(subDt.Rows[i][field.FieldName]).Trim();
                                    if (FieldIsEmpty(field, fieldValue))
                                    {
                                        sysMsg.isPass = false;
                                        sysMsg.Messages.Add(String.Format("{0} - Validation", template.MasterData[activity.Template.MessageField]), String.Format("\"{0}(line:{1})\" is required.", field.DisplayName, i+1));
                                    }
                                }
                            }
                        }
                        if (isEmpty)
                        {
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add(String.Format("{0} - Validation", template.MasterData[activity.Template.MessageField]), String.Format("\"{0}\" is required.", field.DisplayName));
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        //
        // GET: /B2F/
        public ActionResult Detail(string RFQID)
        {
            int dataId = ParseHelper.Parse<int>(RFQID);

            WFTemplate template = new WFTemplate(2, dataId);
            List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_B2F);

            if (dataId > 0)
            {
                B2FQuotationDetail b2Detail = new B2FQuotationDetail();
                b2Detail.FillCategoryData(lfc, dataId);
            }

            ViewBag.WFTemplate = template;
            ViewBag.Categories = lfc;
            ViewBag.DataId = dataId;
            return View();
        }
Esempio n. 6
0
 public ActionResult BatchSubmitVendorRFQ()
 {
     string keyValues = Request.QueryString["NUMBER"];
     SystemMessages sysMsg = WFHelper.CreateMessages();
     string errorMsg = string.Empty;
     if (!string.IsNullOrEmpty(keyValues))
     {
         string[] numbers = keyValues.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         SupplierRFQDetail sr = new SupplierRFQDetail();
         foreach (string number in numbers)
         {
             using (TScope ts = new TScope())
             {
                 SystemMessages msg = WFHelper.CreateMessages();
                 int id = sr.GetSupplierRFQId(number);
                 WFTemplate wfTemplate = new WFTemplate("SUPPLIERWF", id, number);
                 wfTemplate.FirstActivity.CheckData(msg);
                 if (!msg.isPass)
                 {
                     ts.Rollback();
                     sysMsg.isPass = false;
                     sysMsg.Messages.Add("Submit Fail", msg.MessageString);
                 }
                 else
                 {
                     sr.UpdateSupplierRfqStatus(id, number);
                     SkipRFQWFToNextForVVI(id, msg);
                     wfTemplate.LastActivity.DoAction();
                     sysMsg.Messages.Add("Submit Success", string.Format("{0} Submit Success", number));
                 }
             }
         }
     }
     return Json(sysMsg);
 }
Esempio n. 7
0
        public ActionResult SUPPLIERRFQSaveData()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string postData = Request["postData"];
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;
            string number = Convert.ToString(jsonData["number"]);
            bool isOutOfCapability;
            id = SupplierRfqSave(postData, sysMsg, out isOutOfCapability);
            WFTemplate wfTemplate = new WFTemplate("SUPPLIERWF", id, number);

            string wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Esempio n. 8
0
        /// <summary>
        /// Supplier RFQ workflow
        /// </summary>
        /// <returns></returns>
        public ActionResult SUPPLIERRFQWFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            string postData = Request["postData"];
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;
            string number = Convert.ToString(jsonData["number"]);
            int id = 0;
            WFTemplate wfTemplate;
            string wfStatus = string.Empty;

            using (TScope ts = new TScope())
            {
                bool isOutOfCapability;
                id = SupplierRfqSave(postData, sysMsg, out isOutOfCapability);
                wfTemplate = new WFTemplate("SUPPLIERWF", id, number);
                if (!isOutOfCapability)
                {
                    wfTemplate.FirstActivity.CheckData(sysMsg);
                }

                SkipRFQWFToNextForVVI(id, sysMsg);

                if (!sysMsg.isPass)
                {
                    ts.Rollback();
                }
                else
                {
                    //Send Email To VVI Team
                    wfTemplate.LastActivity.DoAction();
                }
            }

            wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Esempio n. 9
0
        /// <summary>
        /// Update  RFQ VVI Value  & Submit RFQ VVI to next stage
        /// </summary>
        /// <returns></returns>
        public ActionResult RFQVVISaveAndSubmit()
        {
            VVIRFQManager vvirfdetail = new VVIRFQManager();
            SystemMessages sysmgs = new SystemMessages();

            VVIRFQManager.SavaAndCheckData(ref vvirfdetail, ref sysmgs, Request);

            WFTemplate wfTemplate = new WFTemplate("VVIWF", vvirfdetail.ID.Value);

            if (sysmgs.isPass)
            {
                try
                {
                    sysmgs.Merge(wfTemplate.Run());
                }
                catch (Exception ex)
                {
                    sysmgs.isPass = false;
                    sysmgs.Messages.Add("System Exception", ex.Message);
                }
            }
            string[] WFIDS = { "104" };
            string PDFDIV = "";
            if (WFIDS.Contains(wfTemplate.CurrentActivity.ID.ToString()))
            {
                if (wfTemplate.CurrentActivity.ID == 104)
                {
                    VVIRFQManager.UpdateOperationForPostBack(vvirfdetail.ID.Value.ToString());

                }
                PDFDIV = @"<button id=""btnDownlPDF"" class=""btn btn-purple""   onclick=""return downloadpdf();"" >
                                                                 Download PDF
                                                                <i class=""icon-file small-30""></i>
                                                                 </button>";
            }

            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQVVIDetail(vvirfdetail, wfTemplate.CurrentActivity.ID.ToString()),
                RFQNumber = vvirfdetail.Number,
                RFQID = vvirfdetail.RFQID,
                ID = vvirfdetail.ID,
                SysMsg = sysmgs,
                PDF = PDFDIV
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 10
0
        //public ActionResult SupplierPricingDetail(SGP.BLL.Models.VVIRFQManager vvrfq)
        //{
        //    int id = 0;
        //    if (Request.QueryString["ID"] != null)
        //    {
        //        int.TryParse(Request.QueryString["ID"], out id);
        //        vvrfq = VVIRFQManager.GetDetail(id)[0];
        //    }
        //    return View(vvrfq);
        //}
        public ActionResult SupplierPricingDetail(string ID, string number)
        {
            int dataId = ParseHelper.Parse<int>(ID);

            WFTemplate template = new WFTemplate(4, dataId, number);
            List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_SGPFORSUPPLIER);

            if (dataId > 0)
            {
                SupplierRFQDetail vd = new SupplierRFQDetail(lfc, dataId, number);
                //vd.FillCategoryData(lfc, dataId, number);
                //vd.InitAutoCalculateColumns(lfc);
            }

            ViewBag.WFTemplate = template;
            ViewBag.Categories = lfc;
            ViewBag.DataId = dataId;
            ViewBag.Number = number;
            ViewBag.wfStatus = template.Status == WorkflowStatus.Finished ? "Finished" : "";
            return View("SupplierPricingDetail");
        }
Esempio n. 11
0
        public ActionResult WFRun(string KeyValues)
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            if (!String.IsNullOrEmpty(KeyValues))
            {
                string[] ids = KeyValues.Split(',');
                if (ids != null && ids.Length > 0)
                {
                    using (TScope ts = new TScope())
                    {
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id))
                            {
                                int entityId = 0;
                                if (int.TryParse(id, out entityId))
                                {
                                    try
                                    {
                                        WFTemplate wfTemplate = new WFTemplate("DefaultWF", entityId);
                                        sysMsg.Merge(wfTemplate.Run());
                                    }
                                    catch (Exception ex)
                                    {
                                        sysMsg.isPass = false;
                                        sysMsg.Messages.Add("System Exception", ex.Message);
                                    }
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("ID Error", String.Format("[{0}] is not a valid ID", id));
                                }
                            }
                        }

                        if (!sysMsg.isPass)
                        {
                            ts.Rollback();
                        }
                    }
                }
            }

            return Json(sysMsg);
        }
Esempio n. 12
0
        /// <summary>
        /// RFQ VVI skip stage
        /// </summary>
        /// <returns></returns>
        public ActionResult RFQVVISaveAndSkip()
        {
            VVIRFQManager vvirfdetail = new VVIRFQManager();
            SystemMessages sysmgs = new SystemMessages();
            VVIRFQManager.SavaAndCheckData(ref vvirfdetail, ref sysmgs, Request);
            WFTemplate wfTemplate = new WFTemplate("VVIWF", vvirfdetail.ID);
            if (sysmgs.isPass)
            {
                string toActivityId = Request.Form["toActivityId"];
                int toActId = 0;
                int.TryParse(toActivityId, out toActId);

                if (toActId > 0)
                {
                    try
                    {

                        sysmgs.Merge(wfTemplate.Skip(toActId));
                    }
                    catch (Exception ex)
                    {
                        sysmgs.isPass = false;
                        sysmgs.Messages.Add("System Exception", ex.Message);
                    }
                }
            }
            string[] WFIDS = { "3", "4", "5", "6", "7" };
            string PDFDIV = "";
            if (WFIDS.Contains(wfTemplate.CurrentActivity.ID.ToString()))
            {
                PDFDIV = @"<button id=""btnDownlPDF"" class=""btn btn-purple"" onclick=""return downloadpdf();"" >
                                                                 Download PDF
                                                                <i class=""icon-file small-30""></i>
                                                                 </button>";
            }

            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQVVIDetail(vvirfdetail, wfTemplate.CurrentActivity.ID.ToString()),
                RFQNumber = vvirfdetail.Number,
                RFQID = vvirfdetail.RFQID,
                ID = vvirfdetail.ID,
                SysMsg = sysmgs,
                PDF = PDFDIV
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 13
0
 public static WFActivity FillActivity(DataRow dr, WFTemplate template)
 {
     WFActivity wfActivity = ModelHandler<WFActivity>.FillModel(dr);
     wfActivity.Template = template;
     if (template != null)
     {
         wfActivity.TemplateID = template.ID;
     }
     return wfActivity;
 }
Esempio n. 14
0
        public ActionResult SaveRequoteData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();

            ReQuote(ref rfdetail, ref sysmgs);

            SGP.BLL.WF.WFTemplate wf = new WFTemplate(1, rfdetail.RFQID);
            // string aa = Request.Form["Number"];
            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQDetail(rfdetail, wf.CurrentActivity.ID.ToString()),
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 15
0
        //
        // GET: /Workflow/
        public ActionResult GetCurrentAndToActivity()
        {
            string templateName = Request["templateName"];
            int entityId = ParseHelper.Parse<int>(Request["entityId"]);
            int toId = ParseHelper.Parse<int>(Request["toId"]);

            WFTemplate template = new WFTemplate(templateName, entityId);

            string jsonData = "{\"currentActivity\":{";

            WFActivity act = null;

            if (template.CurrentActivity != null)
            {
                act = template.CurrentActivity;
                jsonData += String.Format("\"id\":{0},\"name\":{1},\"desc\":{2},\"sort\":{3},\"child\":[", act.ID, Newtonsoft.Json.JsonConvert.SerializeObject(act.Name), Newtonsoft.Json.JsonConvert.SerializeObject(act.Description), act.Sort);

                if (act.CurrentChildActivities.Count > 0)
                {
                    if (act.CurrentUserChildActivities.Count > 0)
                    {
                        foreach (WFActivity cuca in act.CurrentUserChildActivities)
                        {
                            jsonData += "{" + String.Format("\"id\":{0},\"name\":{1},\"desc\":{2},\"sort\":{3}", cuca.ID, Newtonsoft.Json.JsonConvert.SerializeObject(cuca.Name), Newtonsoft.Json.JsonConvert.SerializeObject(cuca.Description), cuca.Sort) + "},";
                        }
                        jsonData = jsonData.TrimEnd(',');
                    }
                    else
                    {
                        string desc = "";
                        foreach (WFActivity cca in act.CurrentChildActivities)
                        {
                            desc += String.Format("You have no permission to submit this, the current user for [{0}] are:Owner:{1}<br>", cca.Name, cca.OwnerUser);
                        }
                        jsonData += "{" + String.Format("\"id\":{0},\"name\":{1},\"desc\":{2},\"sort\":{3}", -999, Newtonsoft.Json.JsonConvert.SerializeObject(""), Newtonsoft.Json.JsonConvert.SerializeObject(desc), 1) + "}";
                    }
                }

                jsonData += "]";
            }
            jsonData += "},\"toActivity\":{";

            if (toId > 0)
            {
                act = template.Activities.Get(toId);
                if (act != null)
                {
                    jsonData += String.Format("\"id\":{0},\"name\":{1},\"desc\":{2},\"sort\":{3},\"child\":[", act.ID, Newtonsoft.Json.JsonConvert.SerializeObject(act.Name), Newtonsoft.Json.JsonConvert.SerializeObject(act.Description), act.Sort);
                    if (act.MatchChildActivities.Count > 0)
                    {
                        foreach (WFActivity cuca in act.MatchChildActivities)
                        {
                            jsonData += "{" + String.Format("\"id\":{0},\"name\":{1},\"desc\":{2},\"sort\":{3}", cuca.ID, Newtonsoft.Json.JsonConvert.SerializeObject(cuca.Name), Newtonsoft.Json.JsonConvert.SerializeObject(cuca.Description), cuca.Sort) + "},";
                        }
                        jsonData = jsonData.TrimEnd(',');
                    }

                    jsonData += "]";
                }
            }

            jsonData += "}}";

            return Content(jsonData);
        }
Esempio n. 16
0
        public ActionResult WFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();
            string html = "";
            string wfStatus = "";

            string postData = Request["postData"];
            int id = Save(postData, sysMsg);

            if (sysMsg.isPass && id > 0)
            {
                List<int> lstToChildIds = new List<int>();
                string templateName = Request["templateName"];
                string toChildIds = Request["toChildIds"];
                int entityId = id;
                int fromId = ParseHelper.Parse<int>(Request["fromId"]);
                int toId = ParseHelper.Parse<int>(Request["toId"]);
                bool checkData = !(Request["checkData"] == "false");
                bool waitAllChildComplated = !(Request["waitAllChildComplated"] == "false");

                if (!String.IsNullOrWhiteSpace(toChildIds))
                {
                    foreach (string stcid in toChildIds.Split(','))
                    {
                        int tcid = ParseHelper.Parse<int>(stcid);
                        if (tcid > 0)
                        {
                            lstToChildIds.Add(Convert.ToInt32(tcid));
                        }
                    }
                }

                WFTemplate wfTemplate = new WFTemplate(templateName, entityId);

                using (TScope ts = new TScope())
                {
                    if (toId == 0)
                    {
                        sysMsg.Merge(wfTemplate.Run(fromId, checkData));
                    }
                    else
                    {
                        sysMsg.Merge(wfTemplate.Skip(toId, fromId, checkData, waitAllChildComplated, lstToChildIds.ToArray()));
                    }

                    if (!sysMsg.isPass)
                    {
                        ts.Rollback();
                    }
                }

                B2FQuotationDetail b2Detail = new B2FQuotationDetail();
                List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_B2F);
                b2Detail.FillCategoryData(lfc, id);
                html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
                wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            }
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Esempio n. 17
0
        public ActionResult GetWizardDataForSupplierRfq(string number)
        {
            string templateName = Request["templateName"];
            string entityId = Request["entityId"];
            int eid = 0;
            int.TryParse(entityId, out eid);

            WFTemplate template = new WFTemplate(templateName, eid, number);

            string jsonData = "{\"activites\":[";

            foreach (WFActivity act in template.Activities)
            {
                jsonData += "{" + String.Format("\"id\":{0},\"name\":{1}, \"sort\":{2},\"activityType\":{3},\"activityDeac\":{4},\"child\":[", act.ID, Newtonsoft.Json.JsonConvert.SerializeObject(act.Name), act.Sort, Newtonsoft.Json.JsonConvert.SerializeObject(act.ActivityType), Newtonsoft.Json.JsonConvert.SerializeObject(act.Description));
                WFActivityCollection mcas = (eid == 0 || eid == -1) ? act.ChildActivities : act.MatchChildActivities;
                foreach (WFActivity cca in mcas)
                {
                    jsonData += "{" + String.Format("\"id\":{0},\"name\":{1}, \"sort\":{2},\"activityType\":{3},\"activityDeac\":{4}", cca.ID, Newtonsoft.Json.JsonConvert.SerializeObject(cca.Name), cca.Sort, Newtonsoft.Json.JsonConvert.SerializeObject(cca.ActivityType), Newtonsoft.Json.JsonConvert.SerializeObject(cca.Description)) + "},";
                }
                jsonData = jsonData.TrimEnd(',');
                jsonData += "]},";
            }

            jsonData = jsonData.TrimEnd(',');
            jsonData += "]";

            WFActivity curAct = null;
            if (eid == -1)
            {
                curAct = template.LastActivity;
            }
            else if (template.CurrentActivity != null)
            {
                curAct = template.CurrentActivity;
            }

            if (curAct != null)
            {
                jsonData += ",\"currentActivity\":{" + String.Format("\"id\":{0},\"name\":{1}, \"sort\":{2}, \"type\":{3}, \"child\":[", curAct.ID, Newtonsoft.Json.JsonConvert.SerializeObject(curAct.Name), curAct.Sort, Newtonsoft.Json.JsonConvert.SerializeObject(curAct.ActivityType));
                foreach (WFActivity cca in curAct.CurrentChildActivities)
                {
                    jsonData += "{" + String.Format("\"id\":{0},\"name\":{1}, \"sort\":{2},\"activityType\":{3},\"activityDeac\":{4}", cca.ID, Newtonsoft.Json.JsonConvert.SerializeObject(cca.Name), cca.Sort, Newtonsoft.Json.JsonConvert.SerializeObject(cca.ActivityType), Newtonsoft.Json.JsonConvert.SerializeObject(cca.Description)) + "},";
                }
                jsonData = jsonData.TrimEnd(',');
                jsonData += "]}";
            }

            jsonData += "}";

            return Content(jsonData);
        }
Esempio n. 18
0
        public ActionResult GetCurrentUserChildActivities()
        {
            string templateName = Request["templateName"];
            string entityId = Request["entityId"];
            int eid = 0;
            int.TryParse(entityId, out eid);
            WFTemplate wfTemplate = new WFTemplate(templateName, eid);

            string jsonData = "{\"activites\":[";
            if (wfTemplate.CurrentActivity != null && wfTemplate.CurrentActivity.CurrentUserChildActivities.Count > 0)
            {
                foreach (WFActivity wa in wfTemplate.CurrentActivity.CurrentUserChildActivities)
                {
                    jsonData += StringHelper.WFActivityToJSON(wa) + ",";
                }

                jsonData = jsonData.TrimEnd(',');
            }
            jsonData += "]}";
            return Content(jsonData);
        }
Esempio n. 19
0
        public ActionResult WFRunSkips(string KeyValues, string ToID)
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            string toActivityId = ToID;
            int toActId = 0;
            int.TryParse(toActivityId, out toActId);

            if (!String.IsNullOrEmpty(KeyValues))
            {
                string[] ids = KeyValues.Split(',');
                if (ids != null && ids.Length > 0)
                {
                    using (TScope ts = new TScope())
                    {
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id))
                            {
                                int entityId = 0;
                                if (int.TryParse(id, out entityId))
                                {
                                    try
                                    {
                                        WFTemplate wfTemplate = new WFTemplate("DefaultWF", entityId);
                                        if (RFQManager.IsPendingStatus(entityId, toActId) == false)
                                        {
                                            sysMsg.isPass = false;
                                            sysMsg.Messages.Add("System Exception", "the HitRate Status is Pending, do not allow go to the Closure Status");
                                        }
                                        else
                                        {
                                            sysMsg.Merge(wfTemplate.Skip(toActId));
                                        }
                                        RFQManager.PostRFQToVVI(entityId);
                                    }
                                    catch (Exception ex)
                                    {
                                        sysMsg.isPass = false;
                                        sysMsg.Messages.Add("System Exception", ex.Message);
                                    }
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("ID Error", String.Format("[{0}] is not a valid ID", id));
                                }
                            }
                        }

                        if (!sysMsg.isPass)
                        {
                            ts.Rollback();
                        }
                    }
                }
            }

            return Json(sysMsg);
        }
Esempio n. 20
0
        public ActionResult VVIWFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();
            string html = "";
            string wfStatus = "";
            string PDFDIV = "";
            string postData = Request["postData"];
            int id = VVISave(postData, sysMsg);

            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;
            Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;
            Dictionary<string, object> productiondata = data["24"] as Dictionary<string, object>;

            if (sysMsg.isPass && id > 0)
            {
                List<int> lstToChildIds = new List<int>();
                string templateName = Request["templateName"];
                string toChildIds = Request["toChildIds"];
                int entityId = id;
                int fromId = ParseHelper.Parse<int>(Request["fromId"]);
                int toId = ParseHelper.Parse<int>(Request["toId"]);
                bool checkData = !(Request["checkData"] == "false");
                bool waitAllChildComplated = !(Request["waitAllChildComplated"] == "false");

                if (!String.IsNullOrWhiteSpace(toChildIds))
                {
                    foreach (string stcid in toChildIds.Split(','))
                    {
                        int tcid = ParseHelper.Parse<int>(stcid);
                        if (tcid > 0)
                        {
                            lstToChildIds.Add(Convert.ToInt32(tcid));
                        }
                    }
                }

                WFTemplate wfTemplate = new WFTemplate(templateName, entityId);
                using (TScope ts = new TScope())
                {
                    if (toId == 0)
                    {
                        sysMsg.Merge(wfTemplate.Run(fromId, checkData));
                    }
                    else
                    {
                        sysMsg.Merge(wfTemplate.Skip(toId, fromId, checkData, waitAllChildComplated, lstToChildIds.ToArray()));
                    }

                    if (productiondata.ContainsKey("vendorrfqid") && (toId == 104 || wfTemplate.NextActivity.ID == 104))
                    {

                        if (string.IsNullOrEmpty(productiondata["vendorrfqid"].ToString()) == false)
                        {

                            try
                            {

                                VVIQuotationDetail dm = new VVIQuotationDetail();
                                if (dm.CheckMainRFQStatusByID(id))
                                {
                                    DbHelperSQL.ExecuteSql("exec SP_VVIPostBackSGP @EntityID,@VendorRFQNumber ", new SqlParameter("@EntityID", entityId), new SqlParameter("@VendorRFQNumber", productiondata["vendorrfqid"].ToString()));
                                    sysMsg.isPass = true;
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("Error", "Main RFQ status is not TechnicalCosting stage.");
                                }
                            }
                            catch (Exception ex)
                            {
                                sysMsg.isPass = false;
                                sysMsg.Messages.Add("error", ex.Message);
                            }

                        }
                    }

                    if (!sysMsg.isPass)
                    {
                        ts.Rollback();
                    }
                }

                VVIQuotationDetail b2Detail = new VVIQuotationDetail();
                List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_VVI);
                b2Detail.FillCategoryData(lfc, id);
                html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
                wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            }

            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                PDF = PDFDIV,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Esempio n. 21
0
 public ActionResult RefreshVVIProductInformation()
 {
     int id = 0;
     string postData = Request["postData"];
     System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
     Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;
     Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;
     string dataId = Convert.ToString(jsonData["dataId"]);
     List<FieldCategory> lfc = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);
     Int32.TryParse(dataId, out id);
     string content = "";
     WFTemplate template = new WFTemplate(3, id);
     if (id > 0)
     {
         VVIQuotationDetail vviDetail = new VVIQuotationDetail();
         vviDetail.FillCategoryData(lfc, id);
     }
     foreach (FieldCategory fc in lfc)
     {
         if (fc.CategoryName == "VVI-Product Information")
         {
             content = BI.SGP.BLL.UIManager.DetailUIHelper.GenrateCategorySubFieldsForVVI(fc);
         }
     }
     var jsonObject = new { content = content };
     return Json(jsonObject, JsonRequestBehavior.AllowGet);
 }
Esempio n. 22
0
        public ActionResult SaveData()
        {
            SystemMessages sysMsg = new SystemMessages();
            string html = "";
            string wfStatus = "";
            int id = 0;
            string postData = Request["postData"];
            id = Save(postData, sysMsg);

            if (id > 0 && sysMsg.isPass)
            {
                WFTemplate wfTemplate = new WFTemplate(2, id);
                B2FQuotationDetail b2Detail = new B2FQuotationDetail();
                List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_B2F);
                b2Detail.FillCategoryData(lfc, id);
                html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
                wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            }
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Esempio n. 23
0
        public ActionResult SaveSubmitData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();

            Save(ref rfdetail, ref sysmgs);
            WFTemplate wfTemplate = new WFTemplate("DefaultWF", rfdetail.RFQID);

            if (sysmgs.isPass)
            {
                try
                {

                    if (RFQManager.IsPendingStatus(rfdetail.RFQID, wfTemplate.NextActivity.ID) == false)
                    {
                        sysmgs.isPass = false;
                        sysmgs.Messages.Add("System Exception", "the HitRate Status is Pending, do not allow go to the Closure Status");
                    }
                    else
                    {
                        sysmgs.Merge(wfTemplate.Run());
                    }
                    RFQManager.PostRFQToVVI(rfdetail.RFQID);
                }
                catch (Exception ex)
                {
                    sysmgs.isPass = false;
                    sysmgs.Messages.Add("System Exception", ex.Message);
                }
            }
            string[] WFIDS = { "5", "6", "7" };
            string PDFDIV = "";
            if (WFIDS.Contains(wfTemplate.CurrentActivity.ID.ToString()))
            {
                PDFDIV = @"<button id=""btnDownlPDF"" class=""btn btn-purple""   onclick=""return downloadpdf();"" >
                                                                 Download PDF
                                                                <i class=""icon-file small-30""></i>
                                                                 </button>";
            }

            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQDetail(rfdetail, wfTemplate.CurrentActivity.ID.ToString()),
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs,
                PDF = PDFDIV
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Esempio n. 24
0
 /// <summary>
 /// Skip the workflow of RFQ for VVI to next activity
 /// </summary>
 /// <param name="id"></param>
 /// <param name="sysMsg"></param>
 /// Lance Chen 20150128
 private void SkipRFQWFToNextForVVI(int id, SystemMessages sysMsg)
 {
     WFTemplate vviTemplate = new WFTemplate(3, id);
     if (vviTemplate.CurrentActivity.ID == 102)
     {
         sysMsg.Merge(vviTemplate.Skip(vviTemplate.NextActivity.ID, 0, false, false));
     }
 }
Esempio n. 25
0
        public ActionResult SubmitData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();
            try
            {
                WFTemplate wfTemplate = new WFTemplate("DefaultWF", rfdetail.RFQID);
                sysmgs.Merge(wfTemplate.Run());
            }
            catch (Exception ex)
            {
                sysmgs.isPass = false;
                sysmgs.Messages.Add("System Exception", ex.Message);
            }

            var returnData = new
            {
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }