Ejemplo n.º 1
0
        public static void RegisterEngines(ViewEngineCollection engines)
        {
            Liquid.UseRubyDateFormat = true;
            Template.RegisterTag<Form>("form");
            Template.RegisterSafeType(typeof(Tag), o => { return o; });

            // Register custom contains condition
            Condition.Operators["contains"] = (left, right) => ContainsMethod(left, right);

            //Condition.Operators["contains"] = (left, right) => (left is ILiquidContains) ? ((ILiquidContains)left).Contains(right) : ((left is string) ? !(right == null || left == null) ? false : ((string)left).Contains((string)right) : false);

            var filters = new[] { typeof(ModelFilters), typeof(TranslationFilter) };
            var themesPath = ConfigurationManager.AppSettings["ThemeCacheFolder"];
            var viewLocator = new FileThemeViewLocator(themesPath);
            var viewParser = new LiquidTemplateParser(themesPath);
            engines.Add(new DotLiquidViewEngine(new DotLiquidFileSystemFactory(viewLocator), viewLocator, viewParser, filters));
        }
        public JsonResult ShipOrderByQty(string OrderNoStr, string SequenceStr, string CurrentShipQtyStr)
        {
            try
            {
                if (!string.IsNullOrEmpty(OrderNoStr))
                {
                    string[] orderNoArray = OrderNoStr.Split(',');
                    string[] sequenceArray = SequenceStr.Split(',');
                    string[] currentShipQtyArray = CurrentShipQtyStr.Split(',');
                    IList<ScheduleLineInput> scheduleLineInputList = new List<ScheduleLineInput>();
                    int i = 0;
                    foreach (string orderNo in orderNoArray)
                    {

                        ScheduleLineInput scheduleLineInput = new ScheduleLineInput();
                        scheduleLineInput.EBELN = orderNoArray[i];
                        scheduleLineInput.EBELP = sequenceArray[i];
                        scheduleLineInput.ShipQty = int.Parse(currentShipQtyArray[i]);
                        scheduleLineInputList.Add(scheduleLineInput);
                        i++;
                    }
                    IpMaster ipMaster = this.orderMgr.ShipScheduleLine(scheduleLineInputList);
                    object obj = new { SuccessMessage = string.Format(Resources.ORD.OrderMaster.ScheduleLine_Shipped), IpNo = ipMaster.IpNo };
                    return Json(obj);
                }
                else
                {
                    throw new BusinessException(Resources.EXT.ControllerLan.Con_ShippingDetailCanNotBeEmpty);
                }
            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return Json(null);
            }
        }
        public JsonResult ShipOrder(string idStr, string qtyStr)
        {
            try
            {
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(idStr))
                {
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');

                    for (int i = 0; i < qtyArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));

                            OrderDetailInput input = new OrderDetailInput();
                            input.ShipQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                }
                if (orderDetailList.Count() == 0)
                {
                    throw new BusinessException(Resources.EXT.ControllerLan.Con_ShippingDetailCanNotBeEmpty);
                }

                IpMaster ipMaster = orderMgr.ShipOrder(orderDetailList);
                SaveSuccessMessage(Resources.EXT.ControllerLan.Con_ShipSuccessfully);
                object obj = new { SuccessMessage = string.Format(Resources.ORD.OrderMaster.ScheduleLine_Shipped), IpNo = ipMaster.IpNo };
                return Json(obj);
            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return Json(null);
            }
        }
		/** Graph update thread.
		 * Async graph updates will be executed by this method in another thread.
		 */
		void ProcessGraphUpdatesAsync () {
			var handles = new [] { graphUpdateAsyncEvent, exitAsyncThread };

			while(true) {
				// Wait for the next batch or exit event
				var handleIndex = WaitHandle.WaitAny(handles);

				if (handleIndex == 1) {
					// Exit even was fired
					//Abort thread and clear queue
					graphUpdateQueueAsync.Clear ();
					asyncGraphUpdatesComplete.Set ();
					return;
				}

				while (graphUpdateQueueAsync.Count > 0) {
					GUOSingle aguo = graphUpdateQueueAsync.Dequeue ();

					try {
						if (aguo.order == GraphUpdateOrder.GraphUpdate) {
							aguo.graph.UpdateArea (aguo.obj);
						} else if (aguo.order == GraphUpdateOrder.FloodFill) {
							FloodFill ();
						} else {
							throw new System.NotSupportedException ("" + aguo.order);
						}
					} catch (System.Exception e) {
						Debug.LogError ("Exception while updating graphs:\n"+e);
					}
				}

				// Done
				asyncGraphUpdatesComplete.Set ();
			}
		}
Ejemplo n.º 5
0
        /// <summary>Creates a damage-level version of a material that uses a shader with the _DamageLevel property.</summary>
        private Material GetDamagedVersion(Material sourceMat, int version)
        {
            if (sourceMat == null)
                return null;
            Material newMaterial = null;
            if (sourceMat.HasProperty("_DamageLevel"))
            {
                newMaterial = new Material(sourceMat);
                // Legacy Pre-Unity5 DestroyIt shader
                switch (version)
                {
                    case 1:
                        newMaterial.SetFloat("_DamageLevel", 0.2f);
                        newMaterial.name = sourceMat.name + "_D1";
                        break;
                    case 2:
                        newMaterial.SetFloat("_DamageLevel", 0.4f);
                        newMaterial.name = sourceMat.name + "_D2";
                        break;
                    case 3:
                        newMaterial.SetFloat("_DamageLevel", 0.6f);
                        newMaterial.name = sourceMat.name + "_D3";
                        break;
                    case 4:
                        newMaterial.SetFloat("_DamageLevel", 0.8f);
                        newMaterial.name = sourceMat.name + "_D4";
                        break;
                    default:
                        return null;
                }
            }
            else if ((sourceMat.shader.name.ToLower() == "standard" || sourceMat.shader.name.ToLower() == "standard (specular setup)") && sourceMat.HasProperty("_DetailMask"))
            {
                // Unity 5 PBR material
                newMaterial = Object.Instantiate(sourceMat);

                // Get the name of the detail mask this shader is using.
                Texture detailMask = sourceMat.GetTexture("_DetailMask");
                if (detailMask == null)
                {
                    //Debug.LogWarning("No DetailMask texture found on shader for Progressive Damage material \"" + sourceMat.name + "\". You need to supply a DetailMask texture for progressive damage to work.");
                    return newMaterial;
                }
                List<string> stringsToRemove = new[] { "_D0", "_D1", "_D2", "_D3", "_D4" }.ToList();
                var sb = new StringBuilder(detailMask.name);
                foreach (string unwanted in stringsToRemove)
                    sb = sb.Replace(unwanted, string.Empty);

                string detailMaskBaseName = sb.ToString().Trim();
                Texture tex;

                switch (version)
                {
                    case 1:
                        tex = detailMasks.Find(x => x.name == detailMaskBaseName + "_D1");
                        if (tex == null)
                            Debug.LogWarning("[DestroyIt Progressive Damage] Could not find Detail Mask \"" + detailMaskBaseName + "_D1\" in Material Preloader. You need to put a detail mask for each damage level (0-4) in the Material Preloader component.");
                        newMaterial.SetTexture("_DetailMask", tex);
                        newMaterial.name = sourceMat.name + "_D1";
                        break;
                    case 2:
                        tex = detailMasks.Find(x => x.name == detailMaskBaseName + "_D2");
                        if (tex == null)
                            Debug.LogWarning("[DestroyIt Progressive Damage] Could not find Detail Mask \"" + detailMaskBaseName + "_D2\" in Material Preloader. You need to put a detail mask for each damage level (0-4) in the Material Preloader component.");
                        newMaterial.SetTexture("_DetailMask", tex);
                        newMaterial.name = sourceMat.name + "_D2";
                        break;
                    case 3:
                        tex = detailMasks.Find(x => x.name == detailMaskBaseName + "_D3");
                        if (tex == null)
                            Debug.LogWarning("[DestroyIt Progressive Damage] Could not find Detail Mask \"" + detailMaskBaseName + "_D3\" in Material Preloader. You need to put a detail mask for each damage level (0-4) in the Material Preloader component.");
                        newMaterial.SetTexture("_DetailMask", tex);
                        newMaterial.name = sourceMat.name + "_D3";
                        break;
                    case 4:
                        tex = detailMasks.Find(x => x.name == detailMaskBaseName + "_D4");
                        if (tex == null)
                            Debug.LogWarning("[DestroyIt Progressive Damage] Could not find Detail Mask \"" + detailMaskBaseName + "_D4\" in Material Preloader. You need to put a detail mask for each damage level (0-4) in the Material Preloader component.");
                        newMaterial.SetTexture("_DetailMask", tex);
                        newMaterial.name = sourceMat.name + "_D4";
                        break;
                    default:
                        return null;
                }
            }
            return newMaterial;
        }
        public JsonResult FlowPrint(string checkedOrders)
        {
            string[] checkedOrderArray = checkedOrders.Split(',');
            string selectStatement = string.Empty;
            IList<object> selectPartyPara = new List<object>();
            foreach (var para in checkedOrderArray)
            {
                if (selectStatement == string.Empty)
                {
                    selectStatement = "from Hu where HuId in (?";
                }
                else
                {
                    selectStatement += ",?";
                }
                selectPartyPara.Add(para);
            }
            selectStatement += ")";

            IList<Hu> huList = base.genericMgr.FindAll<Hu>(selectStatement, selectPartyPara.ToArray());
            foreach (var hu in huList)
            {
                hu.ManufacturePartyDescription = base.genericMgr.FindById<Party>(hu.ManufactureParty).Name;
            }
            string template = systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);
            string reportFileUrl = PrintHuList(huList, template);
            object obj = new { SuccessMessages = string.Format(Resources.INV.Hu.Hu_HuCreatedByOrder), PrintUrl = reportFileUrl };
            return Json(obj);
        }
        public JsonResult CreateHuFX80(string ItemCode, string HuUom, decimal HuUnitCount, string LotNo, decimal HuQty, string ManufactureParty, bool isExport, string supplierLotNo)
        {
            var user = SecurityContextHolder.Get();
            Item item = genericMgr.FindById<Item>(ItemCode);
            item.HuUom = HuUom;
            item.HuUnitCount = HuUnitCount;
            // item.supplierLotNo = supplierLotNo;
            item.HuQty = HuQty;
            item.ManufactureParty = user.Code;
            item.LotNo = LotNo;
            item.supplierLotNo = supplierLotNo;
            IList<Hu> huList = huMgr.CreateHu(item);
            string huTemplate = this.systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);
            foreach (var hu in huList)
            {
                hu.ManufacturePartyDescription = base.genericMgr.FindById<Party>(hu.ManufactureParty).Name;
            }
            if (isExport)
            {
                IList<PrintHu> printHuList = Mapper.Map<IList<Hu>, IList<PrintHu>>(huList);
                IList<object> data = new List<object>();
                data.Add(printHuList);
                data.Add(CurrentUser.FullName);

                reportGen.WriteToClient(huTemplate, data, huTemplate);
                return Json(null);
            }
            else
            {
                string printUrl = PrintHuList(huList, huTemplate);
                object obj = new { SuccessMessage = string.Format("条码打印成功,共打印了{0}张条码", huList.Count), PrintUrl = printUrl };
                return Json(obj);
            }
        }
        public JsonResult _PrintHus(string checkedOrders)
        {
            string[] checkedOrderArray = checkedOrders.Split(',');
            string selectStatement = string.Empty;
            IList<object> selectPartyPara = new List<object>();
            foreach (var para in checkedOrderArray)
            {
                if (selectStatement == string.Empty)
                {
                    selectStatement = "from Hu where HuId in (?";
                }
                else
                {
                    selectStatement += ",?";
                }
                selectPartyPara.Add(para);
            }
            selectStatement += ")";

            IList<Hu> huList = genericMgr.FindAll<Hu>(selectStatement, selectPartyPara.ToArray());
            foreach (var hu in huList)
            {
                if (!string.IsNullOrEmpty(hu.ManufactureParty))
                {
                    hu.ManufacturePartyDescription = queryMgr.FindById<Party>(hu.ManufactureParty).Name;
                }
            }
            //string template = "BarCodePurchase2D.xls";//systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);

            List<string> reportFileUrls = new List<string>();

            var huGroups = huList.GroupBy(p => p.HuTemplate);
            foreach (var huGroup in huGroups)
            {
                string reportFileUrl = PrintHuList(huGroup.ToList(), huGroup.Key);
                reportFileUrls.Add(reportFileUrl);
            }

            object obj = new { SuccessMessage = Resources.EXT.ControllerLan.Con_BarcodePrintedSuccessfully, PrintUrl = reportFileUrls };
            return Json(obj);
        }
        public JsonResult CreateHuByOrderDetail(string OrderDetailidStr, string OrderDetailucStr, string OrderDetailsupplierLotNoStr,
            string OrderDetailqtyStr, bool OrderDetailisExport, string OrderDetailimanufactureDateStr)
        {
            try
            {
                IList<OrderDetail> nonZeroOrderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(OrderDetailidStr))
                {
                    string[] manufactureDateArray = OrderDetailimanufactureDateStr.Split(',');
                    string[] idArray = OrderDetailidStr.Split(',');
                    string[] ucArray = OrderDetailucStr.Split(',');
                    string[] supplierLotNoArray = OrderDetailsupplierLotNoStr.Split(',');
                    string[] qtyArray = OrderDetailqtyStr.Split(',');
                    OrderMaster orderMaster = null;

                    if (idArray != null && idArray.Count() > 0)
                    {
                        for (int i = 0; i < idArray.Count(); i++)
                        {
                            //string lotNo = manufactureDateArray[i].Replace("-", "");
                            OrderDetail orderDetail = genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));
                            if (orderMaster == null)
                            {
                                orderMaster = genericMgr.FindById<OrderMaster>(orderDetail.OrderNo);
                                //orderMaster.HuTemplate = orderMaster.HuTemplate.Trim();
                            }

                            orderDetail.UnitCount = Convert.ToDecimal(ucArray[i]);
                            orderDetail.SupplierLotNo = supplierLotNoArray[i];
                            orderDetail.ManufactureDate = Convert.ToDateTime(manufactureDateArray[i]);
                            orderDetail.LotNo = Utility.LotNoHelper.GenerateLotNo(orderDetail.ManufactureDate);

                            orderDetail.ManufactureParty = orderMaster.PartyFrom;
                            orderDetail.HuQty = Convert.ToDecimal(qtyArray[i]);
                            nonZeroOrderDetailList.Add(orderDetail);
                        }
                    }
                    this.genericMgr.CleanSession();
                    if (string.IsNullOrEmpty(orderMaster.HuTemplate))
                    {
                        orderMaster.HuTemplate = this.systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);
                    }

                    if (orderMaster != null)
                    {
                        IList<Hu> huList = huMgr.CreateHu(orderMaster, nonZeroOrderDetailList);
                        foreach (var hu in huList)
                        {
                            if (!string.IsNullOrEmpty(hu.ManufactureParty))
                            {
                                hu.ManufacturePartyDescription = queryMgr.FindById<Party>(hu.ManufactureParty).Name;
                            }
                            if (!string.IsNullOrWhiteSpace(hu.Direction))
                            {
                                hu.Direction = this.genericMgr.FindById<HuTo>(hu.Direction).CodeDescription;
                            }
                        }

                        if (OrderDetailisExport)
                        {
                            IList<PrintHu> printHuList = Mapper.Map<IList<Hu>, IList<PrintHu>>(huList);

                            IList<object> data = new List<object>();
                            data.Add(printHuList);
                            data.Add(CurrentUser.FullName);
                            reportGen.WriteToClient(orderMaster.HuTemplate, data, orderMaster.HuTemplate);
                            return Json(null);
                        }
                        else
                        {
                            string printUrl = PrintHuList(huList, orderMaster.HuTemplate);
                            object obj = new { SuccessMessage = string.Format(Resources.EXT.ControllerLan.Con_BarcodePrintedSuccessfully_1, huList.Count), PrintUrl = printUrl };
                            return Json(obj);
                        }
                    }
                }
                return Json(null);
            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return Json(null);
            }
        }
        public JsonResult CreateHuByIpDetail(string IpDetailidStr, string IpDetailucStr, string IpDetailsupplierLotNoStr, string IpDetailqtyStr,
             bool IpDetailisExport, string FlowremarkStrn, string IpDetailmanufactureDateStr, bool IpDetailisCheckExport)
        {
            try
            {
                IList<IpDetail> nonZeroIpDetailList = new List<IpDetail>();
                if (!string.IsNullOrEmpty(IpDetailidStr))
                {
                    string[] manufactureDateArray = IpDetailmanufactureDateStr.Split(',');
                    string[] idArray = IpDetailidStr.Split(',');
                    string[] ucArray = IpDetailucStr.Split(',');
                    string[] supplierLotNoArray = IpDetailsupplierLotNoStr.Split(',');
                    string[] qtyArray = IpDetailqtyStr.Split(',');
                    string[] remarkArray = FlowremarkStrn.Split(',');
                    IpMaster ipMaster = null;
                    FlowMaster flowMaster = null;

                    if (idArray != null && idArray.Count() > 0)
                    {
                        for (int i = 0; i < idArray.Count(); i++)
                        {
                            IpDetail ipDetail = genericMgr.FindById<IpDetail>(Convert.ToInt32(idArray[i]));
                            if (ipMaster == null)
                            {
                                ipMaster = genericMgr.FindById<IpMaster>(ipDetail.IpNo);
                                //ipMaster.HuTemplate = ipMaster.HuTemplate.Trim();
                                if (!string.IsNullOrEmpty(ipMaster.Flow))
                                {
                                    flowMaster = genericMgr.FindById<FlowMaster>(ipMaster.Flow);
                                }
                            }
                            if (flowMaster != null && flowMaster.UcDeviation >= 0)
                            {
                                var ucDeviation = flowMaster.UcDeviation;
                                ipDetail.MaxUc = ipDetail.UnitCount * Convert.ToDecimal(((ucDeviation / 100) + 1));
                                ipDetail.MinUc = ipDetail.UnitCount * Convert.ToDecimal((1 - (ucDeviation / 100)));
                            }
                            else
                            {
                                ipDetail.MaxUc = decimal.MaxValue;
                                ipDetail.MinUc = 0;
                            }
                            //string lotNo = manufactureDateArray[i].Replace("-", "");
                            ipDetail.UnitCount = Convert.ToDecimal(ucArray[i]);
                            ipDetail.SupplierLotNo = supplierLotNoArray[i];
                            ipDetail.ManufactureParty = ipMaster.PartyFrom;
                            ipDetail.ManufactureDate = Convert.ToDateTime(manufactureDateArray[i]);
                            ipDetail.LotNo = Utility.LotNoHelper.GenerateLotNo(ipDetail.ManufactureDate);
                            ipDetail.Remark = remarkArray[i];
                            //ipDetail.HuQty = Convert.ToDecimal(qtyArray[i]);

                            var qtys = qtyArray[i].Split(' ');
                            if (qtys.Length == 1)
                            {
                                decimal qty = decimal.Parse(qtys[0]);
                                if (qty / ipDetail.UnitCount > 500)
                                {
                                    throw new BusinessException(string.Format(Resources.EXT.ControllerLan.Con_PrintedBarcodeQuantityCanNotExceedFiveHundred));
                                }
                                for (decimal j = 0; j < qty; j += ipDetail.UnitCount)
                                {
                                    var newIpDetail = Mapper.Map<IpDetail, IpDetail>(ipDetail);
                                    newIpDetail.HuQty = (qty - j) < newIpDetail.UnitCount ? (qty - j) : newIpDetail.UnitCount;
                                    if (newIpDetail.HuQty > ipDetail.MaxUc || newIpDetail.HuQty < ipDetail.MinUc)
                                    {
                                        SaveWarningMessage(string.Format(Resources.EXT.ControllerLan.Con_QuantityInputError,
                                                    newIpDetail.Item, ipDetail.MaxUc.ToString("0.##"), ipDetail.MinUc.ToString("0.##")));
                                        object fail1 = new { Fail = "True" };

                                        return Json(fail1);
                                    }
                                    nonZeroIpDetailList.Add(newIpDetail);
                                }
                            }
                            else
                            {
                                for (int j = 0; j < qtys.Length; j++)
                                {
                                    if (qtys[j].Length > 0)
                                    {
                                        var newIpDetail = Mapper.Map<IpDetail, IpDetail>(ipDetail);
                                        newIpDetail.HuQty = Convert.ToDecimal(qtys[j]);
                                        if (newIpDetail.HuQty > ipDetail.MaxUc || newIpDetail.HuQty < ipDetail.MinUc)
                                        {
                                            SaveWarningMessage(string.Format(Resources.EXT.ControllerLan.Con_QuantityInputError,
                                                        newIpDetail.Item, ipDetail.MaxUc.ToString("0.##"), ipDetail.MinUc.ToString("0.##")));
                                            object fail = new { Fail = "True" };

                                            return Json(fail);
                                        }
                                        nonZeroIpDetailList.Add(newIpDetail);
                                    }
                                }
                            }
                        }
                    }
                    this.genericMgr.CleanSession();
                    if (ipMaster != null)
                    {
                        if (IpDetailisCheckExport)
                        {
                            var ipDetailisCheckExport = string.Format("OK");
                            return Json(new { IpDetailisCheckExport = ipDetailisCheckExport });
                        }
                        IList<Hu> huList = huMgr.CreateHu(ipMaster, nonZeroIpDetailList);
                        foreach (var hu in huList)
                        {
                            if (!string.IsNullOrEmpty(hu.ManufactureParty))
                            {
                                hu.ManufacturePartyDescription = queryMgr.FindById<Party>(hu.ManufactureParty).Name;
                            }
                            if (!string.IsNullOrWhiteSpace(hu.Direction))
                            {
                                hu.Direction = this.genericMgr.FindById<HuTo>(hu.Direction).CodeDescription;
                            }
                        }
                        if (string.IsNullOrEmpty(ipMaster.HuTemplate))
                        {
                            ipMaster.HuTemplate = this.systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.DefaultBarCodeTemplate);
                        }
                        if (IpDetailisExport)
                        {

                            IList<PrintHu> printHuList = Mapper.Map<IList<Hu>, IList<PrintHu>>(huList);
                            IList<object> data = new List<object>();
                            data.Add(printHuList);
                            data.Add(CurrentUser.FullName);
                            reportGen.WriteToClient(ipMaster.HuTemplate, data, ipMaster.HuTemplate);
                            return Json(null);
                        }
                        else
                        {
                            string printUrl = PrintHuList(huList, ipMaster.HuTemplate);
                            object obj = new { SuccessMessage = string.Format(Resources.EXT.ControllerLan.Con_BarcodePrintedSuccessfully_1, huList.Count), PrintUrl = printUrl };
                            return Json(obj);
                        }
                    }
                }
                return Json(null);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
                return Json(null);
            }
        }
        public JsonResult CreateHuByFlow(string FlowidStr, string FlowucStr, string FlowsupplierLotNoStr, string FlowqtyStr, bool FlowisExport,
           string FlowmanufactureDateStr, string FlowremarkStr, bool FlowCheckExport)
        {
            try
            {
                IList<FlowDetail> nonZeroFlowDetailList = new List<FlowDetail>();
                if (!string.IsNullOrEmpty(FlowidStr))
                {
                    string[] manufactureDateArray = FlowmanufactureDateStr.Split(',');
                    string[] idArray = FlowidStr.Split(',');
                    string[] ucArray = FlowucStr.Split(',');
                    string[] supplierLotNoArray = FlowsupplierLotNoStr.Split(',');
                    string[] qtyArray = FlowqtyStr.Split(',');
                    string[] remarkArray = FlowremarkStr.Split(',');
                    FlowMaster flowMaster = null;

                    if (idArray != null && idArray.Count() > 0)
                    {
                        for (int i = 0; i < idArray.Count(); i++)
                        {
                            //string lotNo = manufactureDateArray[i].Replace("-", "");
                            FlowDetail flowDetail = genericMgr.FindById<FlowDetail>(Convert.ToInt32(idArray[i]));
                            if (flowMaster == null)
                            {
                                flowMaster = genericMgr.FindById<FlowMaster>(flowDetail.Flow);
                            }
                            if (flowMaster != null && flowMaster.UcDeviation >= 0)
                            {
                                var ucDeviation = flowMaster.UcDeviation;
                                flowDetail.MaxUc = flowDetail.UnitCount * Convert.ToDecimal((ucDeviation / 100) + 1);
                                flowDetail.MinUc = flowDetail.UnitCount * Convert.ToDecimal(1 - (ucDeviation / 100));
                            }
                            else
                            {
                                flowDetail.MaxUc = decimal.MaxValue;
                                flowDetail.MinUc = 0;
                            }

                            flowDetail.ManufactureDate = Convert.ToDateTime(manufactureDateArray[i]);
                            flowDetail.SupplierLotNo = supplierLotNoArray[i];
                            flowDetail.LotNo = Utility.LotNoHelper.GenerateLotNo(flowDetail.ManufactureDate);
                            flowDetail.ManufactureParty = flowMaster.PartyFrom;
                            flowDetail.UnitCount = Convert.ToDecimal(ucArray[i]);
                            flowDetail.Remark = remarkArray[i];

                            var qtys = qtyArray[i].Split(' ');
                            if (qtys.Length == 1)
                            {
                                decimal qty = decimal.Parse(qtys[0]);
                                if (qty / flowDetail.UnitCount > 500)
                                {
                                    throw new BusinessException(string.Format(Resources.EXT.ControllerLan.Con_PrintedBarcodeQuantityCanNotExceedFiveHundred));
                                }

                                for (decimal j = 0; j < qty; j += flowDetail.UnitCount)
                                {
                                    var newFlowDetail = Mapper.Map<FlowDetail, FlowDetail>(flowDetail);
                                    bool isLastHu = (qty - j) <= flowDetail.MaxUc && (qty - j) >= flowDetail.MinUc;
                                    if (isLastHu)
                                    {
                                        newFlowDetail.HuQty = (qty - j);
                                    }
                                    else
                                    {
                                        newFlowDetail.HuQty = (qty - j) < flowDetail.UnitCount ? (qty - j) : flowDetail.UnitCount;
                                    }
                                    if (newFlowDetail.HuQty > flowDetail.MaxUc || newFlowDetail.HuQty < flowDetail.MinUc)
                                    {
                                        SaveWarningMessage(string.Format(Resources.EXT.ControllerLan.Con_QuantityInputError,
                                                    newFlowDetail.Item, flowDetail.MaxUc.ToString("0.##"), flowDetail.MinUc.ToString("0.##")));
                                        object fail1 = new { Fail = "True" };

                                        return Json(fail1);
                                    }
                                    nonZeroFlowDetailList.Add(newFlowDetail);
                                    if (isLastHu) break;
                                }
                            }
                            else
                            {
                                for (int j = 0; j < qtys.Length; j++)
                                {
                                    if (qtys[j].Length > 0)
                                    {
                                        var newFlowDetail = Mapper.Map<FlowDetail, FlowDetail>(flowDetail);
                                        newFlowDetail.HuQty = Convert.ToDecimal(qtys[j]);
                                        if (newFlowDetail.HuQty > flowDetail.MaxUc || newFlowDetail.HuQty < flowDetail.MinUc)
                                        {
                                            SaveWarningMessage(string.Format(Resources.EXT.ControllerLan.Con_QuantityInputError,
                                                    newFlowDetail.Item, flowDetail.MaxUc.ToString("0.##"), flowDetail.MinUc.ToString("0.##")));
                                            object fail = new { Fail = "True" };

                                            return Json(fail);
                                        }
                                        nonZeroFlowDetailList.Add(newFlowDetail);
                                    }
                                }
                            }
                        }
                    }
                    this.genericMgr.CleanSession();
                    if (flowMaster != null)
                    {
                        if (FlowCheckExport)
                        {
                            var flowCheckExport = string.Format("OK");
                            return Json(new { FlowCheckExport = flowCheckExport });
                        }
                        IList<Hu> huList = huMgr.CreateHu(flowMaster, nonZeroFlowDetailList);
                        if (FlowisExport)
                        {

                            foreach (var hu in huList)
                            {
                                if (!string.IsNullOrEmpty(hu.ManufactureParty))
                                {
                                    hu.ManufacturePartyDescription = queryMgr.FindById<Party>(hu.ManufactureParty).Name;
                                }
                                if (!string.IsNullOrWhiteSpace(hu.Direction))
                                {
                                    hu.Direction = this.genericMgr.FindById<HuTo>(hu.Direction).CodeDescription;
                                }
                            }
                            IList<PrintHu> printHuList = Mapper.Map<IList<Hu>, IList<PrintHu>>(huList);
                            IList<object> data = new List<object>();
                            data.Add(printHuList);
                            data.Add(CurrentUser.FullName);
                            reportGen.WriteToClient(flowMaster.HuTemplate, data, flowMaster.HuTemplate);
                            return Json(null);
                        }
                        else
                        {
                            string printUrl = PrintHuList(huList, flowMaster.HuTemplate);
                            object obj = new { SuccessMessage = string.Format(Resources.EXT.ControllerLan.Con_BarcodePrintedSuccessfully_1, huList.Count), PrintUrl = printUrl };
                            return Json(obj);
                        }
                    }
                }
                return Json(null);
            }
            catch (Exception ex)
            {
                return Json(ex.Message);
            }
        }