Esempio n. 1
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. 2
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. 3
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. 4
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. 5
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. 6
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);
        }