public async Task <dynamic> DeclainedNotification(NotificationEntity model)
        {
            int returnValue = 0;

            try
            {
                #region Old
                //Required CompnayID,IsApproved=0,Comments,Isupdate false,isDelete false ,StatusID=1
                //String MessageName = System.Enum.GetName(typeof(workFlowTranEnum_MessageName), (int)workFlowTranEnum_MessageName.Declined);
                //int WorkFlowStatus = new WorkFLowMgt().ExecuteWorkFlowTransactionProcess(new WorkFLowMgt().SetProcedureParamForDeclained(model, (int)model.LoggedCompanyID, (int)workFlowTranEnum_IsApproved.False, model.Comments, (int)workFlowTranEnum_IsUpdate.False, (int)workFlowTranEnum_IsDelete.False, (int)workFlowTranEnum_Status.Active, model.CustomCode, (int)workFlowTranEnum_IsDeclained.True, MessageName));
                //if (WorkFlowStatus == 0)
                //{
                //    NotificationHubs.BroadcastData(new NotificationEntity());
                //    returnValue = 201;
                //}
                #endregion old
                #region New
                returnValue = new WorkFLowMgt().DeclinedProcess(model);
                List <vmNotificationMail> nModel = new WorkFLowMgt().GetNotificationMailObjectListDeclined(model, "");
                foreach (var item in nModel)
                {
                    returnValue = await new EmailService().NotificationMail(item);
                }
                NotificationHubs.BroadcastData(new NotificationEntity());
                returnValue = 201;
                #endregion New
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return(returnValue);
        }
예제 #2
0
        public async Task <dynamic> ApproveNotification(NotificationEntity model)
        {
            int returnValue = 0;

            try
            {
                int WorkFlowStatus = 1;
                if (WorkFlowStatus == 1)
                {
                    returnValue = new WorkFLowMgt().ApproveProcess(model);
                    List <vmNotificationMail> nModel = new WorkFLowMgt().GetNotificationMailObjectList(model, "");
                    foreach (var item in nModel)
                    {
                        returnValue = await new EmailService().NotificationMail(item);
                    }
                    //NotificationHubsSales.BroadcastDataSales(new NotificationEntity());
                    NotificationHubs.BroadcastData(new NotificationEntity());
                    returnValue = 200;
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return(returnValue);
        }
예제 #3
0
        public async Task <dynamic> DeclainedNotification(NotificationEntity model)
        {
            int returnValue = 0;

            try
            {
                #region New
                returnValue = new WorkFLowMgt().DeclinedProcess(model);
                List <vmNotificationMail> nModel = new WorkFLowMgt().GetNotificationMailObjectListDeclined(model, "");
                foreach (var item in nModel)
                {
                    returnValue = await new EmailService().NotificationMail(item);
                }
                //NotificationHubsSales.BroadcastDataSales(new NotificationEntity());
                NotificationHubs.BroadcastData(new NotificationEntity());
                returnValue = 201;
                #endregion New
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            return(returnValue);
        }
예제 #4
0
        public async Task <string> SaveUpdateSetSetupMasterDetail(vmSetSetupMasterDetail ModelMaster, List <vmSetSetupMasterDetail> ModelDetail, vmCmnParameters objcmnParam)
        {
            string result        = string.Empty;
            long   TransactionID = 0;

            using (var transaction = new TransactionScope())
            {
                GFactory_EF_PrdSetMaster = new PrdSetMaster_EF();
                GFactory_EF_PrdSetSetup  = new PrdSetSetup_EF();
                string SetNo = string.Empty; int SetMasterId = 0, SetDetailId = 0;
                long   SetFirstDigit = 0, SetOtherDigits = 0;

                var Masteritem = new PrdSetMaster();
                var SetDetail  = new List <PrdSetSetup>();

                vmSetSetupMasterDetail item  = new vmSetSetupMasterDetail();
                vmSetSetupMasterDetail items = new vmSetSetupMasterDetail();
                //-------------------END----------------------

                if (ModelDetail.Count() > 0)
                {
                    try
                    {
                        using (_ctxCmn = new ERP_Entities())
                        {
                            if (ModelMaster.SetMasterID == 0)
                            {
                                SetMasterId    = Convert.ToInt16(GFactory_EF_PrdSetMaster.getMaxID("PrdSetMaster"));
                                SetDetailId    = Convert.ToInt16(GFactory_EF_PrdSetSetup.getMaxID("PrdSetSetup"));
                                SetFirstDigit  = Convert.ToInt64(SetDetailId.ToString().Substring(0, 1));
                                SetOtherDigits = Convert.ToInt64(SetDetailId.ToString().Substring(1, SetDetailId.ToString().Length - 1));

                                //CustomNo = GFactory_EF_PrdSetSetup.getCustomCode(MenuId, DateTime.Now, CompanyId, 1, 1);
                                //if (CustomNo == null || CustomNo == "")
                                //{
                                //    SetNo = SetDetailId.ToString();
                                //}
                                //else
                                //{
                                //    SetNo = CustomNo;
                                //}
                                TransactionID = SetMasterId;
                                Masteritem    = new PrdSetMaster
                                {
                                    SetMasterID  = SetMasterId,
                                    BuyerID      = ModelMaster.BuyerID,
                                    Description  = ModelMaster.Description,
                                    ItemID       = (long)ModelMaster.ItemID,
                                    PIID         = ModelMaster.PIID,
                                    PIItemlength = ModelMaster.PIItemlength,
                                    RefSetDate   = ModelMaster.RefSetDate,
                                    RefSetID     = ModelMaster.RefSetID,
                                    SetDate      = ModelMaster.SetDate,
                                    SupplierID   = ModelMaster.SupplierID,
                                    StatusID     = ModelMaster.StatusID,
                                    CompanyID    = objcmnParam.loggedCompany,
                                    CreateBy     = objcmnParam.loggeduser,
                                    CreateOn     = DateTime.Now,
                                    CreatePc     = HostService.GetIP(),
                                    IsDeleted    = false
                                };

                                for (int i = 0; i < ModelDetail.Count(); i++)
                                {
                                    item = ModelDetail[i];

                                    var Detailitem = new PrdSetSetup
                                    {
                                        SetID        = Convert.ToInt64(SetFirstDigit + "" + SetOtherDigits),
                                        YarnID       = (long)item.YarnID,
                                        WarpYarnID   = item.YarnID,
                                        WeftYarnID   = item.WeftYarnID,
                                        Weave        = item.Weave,
                                        BuyerID      = item.BuyerID,
                                        ColorID      = item.ColorID,
                                        Description  = item.Description,
                                        EndsPerCreel = item.EndsPerCreel,
                                        LeaseReapet  = item.LeaseRepeat,
                                        MachineSpeed = item.MachineSpeed,
                                        SetDate      = item.SetDate,
                                        ItemID       = (long)item.ItemID,
                                        PIID         = item.PIID,
                                        SetLength    = (long)item.SetLength,
                                        SetMasterID  = SetMasterId,
                                        SetNo        = item.SetNo,
                                        SupplierID   = item.SupplierID,
                                        TotalEnds    = item.TotalEnds,
                                        YarnCount    = item.YarnCount,
                                        YarnRatio    = item.YarnRatio,
                                        YarnRatioLot = item.YarnRatioLot,
                                        NoOfBall     = item.NoOfBall,

                                        CompanyID = objcmnParam.loggedCompany,
                                        CreateBy  = objcmnParam.loggeduser,
                                        CreateOn  = DateTime.Now,
                                        CreatePc  = HostService.GetIP(),
                                        IsDeleted = false
                                    };
                                    //***************************************END*******************************************
                                    SetDetail.Add(Detailitem);
                                    SetOtherDigits++;
                                }
                            }
                            else
                            {
                                var SetMasterAll = GFactory_EF_PrdSetMaster.GetAll().Where(x => x.SetMasterID == ModelMaster.SetMasterID);
                                var SetDetailAll = GFactory_EF_PrdSetSetup.GetAll().Where(x => x.SetMasterID == ModelMaster.SetMasterID);

                                Masteritem              = SetMasterAll.FirstOrDefault(x => x.SetMasterID == ModelMaster.SetMasterID);
                                Masteritem.BuyerID      = ModelMaster.BuyerID;
                                Masteritem.Description  = ModelMaster.Description;
                                Masteritem.ItemID       = (long)ModelMaster.ItemID;
                                Masteritem.PIID         = ModelMaster.PIID;
                                Masteritem.PIItemlength = ModelMaster.PIItemlength;
                                Masteritem.RefSetDate   = ModelMaster.RefSetDate;
                                Masteritem.RefSetID     = ModelMaster.RefSetID;
                                Masteritem.SetDate      = ModelMaster.SetDate;
                                Masteritem.SupplierID   = ModelMaster.SupplierID;
                                Masteritem.StatusID     = ModelMaster.StatusID;
                                Masteritem.CompanyID    = objcmnParam.loggedCompany;
                                Masteritem.UpdateBy     = objcmnParam.loggeduser;
                                Masteritem.UpdateOn     = DateTime.Now;
                                Masteritem.UpdatePc     = HostService.GetIP();
                                Masteritem.IsDeleted    = false;

                                for (int i = 0; i < ModelDetail.Count(); i++)
                                {
                                    item = ModelDetail[i];

                                    foreach (PrdSetSetup d in SetDetailAll.Where(d => d.SetMasterID == ModelMaster.SetMasterID && d.SetID == item.SetID))
                                    {
                                        d.YarnID       = (long)item.YarnID;
                                        d.WarpYarnID   = item.YarnID;
                                        d.WeftYarnID   = item.WeftYarnID;
                                        d.Weave        = item.Weave;
                                        d.BuyerID      = item.BuyerID;
                                        d.ColorID      = item.ColorID;
                                        d.Description  = item.Description;
                                        d.EndsPerCreel = item.EndsPerCreel;
                                        d.LeaseReapet  = item.LeaseRepeat;
                                        d.MachineSpeed = item.MachineSpeed;
                                        d.SetDate      = item.SetDate;
                                        d.ItemID       = (long)item.ItemID;
                                        d.PIID         = item.PIID;
                                        d.SetLength    = (long)item.SetLength;
                                        d.SetNo        = item.SetNo;
                                        d.SupplierID   = item.SupplierID;
                                        d.TotalEnds    = item.TotalEnds;
                                        d.YarnCount    = item.YarnCount;
                                        d.YarnRatio    = item.YarnRatio;
                                        d.YarnRatioLot = item.YarnRatioLot;
                                        d.NoOfBall     = item.NoOfBall;

                                        d.CompanyID = objcmnParam.loggedCompany;
                                        d.UpdateBy  = objcmnParam.loggeduser;
                                        d.UpdateOn  = DateTime.Now;
                                        d.UpdatePc  = HostService.GetIP();
                                        d.IsDeleted = false;

                                        SetDetail.Add(d);
                                        break;
                                    }
                                }
                            }

                            if (ModelMaster.SetMasterID > 0)
                            {
                                if (Masteritem != null)
                                {
                                    GFactory_EF_PrdSetMaster.Update(Masteritem);
                                    GFactory_EF_PrdSetMaster.Save();
                                }
                                if (SetDetail != null && SetDetail.Count != 0)
                                {
                                    GFactory_EF_PrdSetSetup.UpdateList(SetDetail.ToList());
                                    GFactory_EF_PrdSetSetup.Save();
                                }
                            }
                            else
                            {
                                if (Masteritem != null)
                                {
                                    GFactory_EF_PrdSetMaster.Insert(Masteritem);
                                    GFactory_EF_PrdSetMaster.Save();
                                    GFactory_EF_PrdSetMaster.updateMaxID("PrdSetMaster", Convert.ToInt64(SetMasterId));
                                }
                                if (SetDetail != null && SetDetail.Count != 0)
                                {
                                    GFactory_EF_PrdSetSetup.InsertList(SetDetail.ToList());
                                    GFactory_EF_PrdSetSetup.Save();
                                    GFactory_EF_PrdSetSetup.updateMaxID("PrdSetSetup", Convert.ToInt64(SetFirstDigit + "" + (SetOtherDigits - 1)));
                                }
                            }

                            transaction.Complete();
                            result = "1";
                        }
                    }
                    catch (Exception e)
                    {
                        result = "";
                        e.ToString();
                    }
                }
                else
                {
                    result = "";
                    throw new Exception();
                }
            }

            // Approval Code
            #region WorkFlow Transaction Entry and email sending
            if (ModelMaster.SetMasterID == 0)
            {
                UserCommonEntity commonEntity = new UserCommonEntity();
                commonEntity.currentMenuID  = objcmnParam.menuId;
                commonEntity.loggedCompnyID = objcmnParam.loggedCompany;
                commonEntity.loggedUserID   = objcmnParam.loggeduser;
                int workflowID = 0;
                List <vmCmnWorkFlowMaster> listWorkFlow = new WorkFLowMgt().GetWorkFlowMasterListByMenu(commonEntity);
                foreach (vmCmnWorkFlowMaster itemWFM in listWorkFlow)
                {
                    int userTeamID = itemWFM.UserTeamID ?? 0;
                    if (new WorkFLowMgt().checkUserValidation(commonEntity.loggedUserID ?? 0, itemWFM.WorkFlowID) && userTeamID > 0)
                    {
                        itemWFM.WorkFlowTranCustomID = (Int16)TransactionID;
                        workflowID = new WorkFLowMgt().ExecuteTransactionProcess(itemWFM, commonEntity);
                    }
                    if (userTeamID == 0)
                    {
                        itemWFM.WorkFlowTranCustomID = (Int16)TransactionID;
                        workflowID = new WorkFLowMgt().ExecuteTransactionProcess(itemWFM, commonEntity);
                    }
                }

                int mail = 0;
                foreach (vmCmnWorkFlowMaster itemWFM in listWorkFlow)
                {
                    NotificationEntity notification = new NotificationEntity();
                    notification.WorkFlowID    = itemWFM.WorkFlowID;
                    notification.TransactionID = (Int16)TransactionID;
                    List <vmNotificationMail> nModel = new WorkFLowMgt().GetNotificationMailObjectList(notification, "Created");
                    foreach (var mailModel in nModel)
                    {
                        mail = await new EmailService().NotificationMail(mailModel);
                    }
                }
            }
            #endregion WorkFlow Transaction Entry and email sending
            return(result);
        }
예제 #5
0
        /// <summary>
        /// Save Data To Database
        /// <para>Use it when save data through a stored procedure</para>
        /// </summary>
        public int SaveCompanyParam(CmnCompany model, UserCommonEntity commonEntity)
        {
            GenericFactoryFor_Company = new CmnCompany_GF();
            GenericFactoryEF_Company  = new CmnCompany_EF();
            GFactory_EF_CmnCustomCode = new SalCmnCustomCode_EF();
            int result = 0;

            try
            {
                #region CustomCode And Primary Key  Process
                int NextId = Convert.ToInt16(GenericFactoryEF_Company.getMaxID("CmnCompany"));
                model.CompanyID = NextId;
                //......... START for custom code........... //
                //string customCode = "";
                CmnCustomCode objCustomCode = GFactory_EF_CmnCustomCode.FindBy(m => m.MenuID == model.MenuID && m.IsDeleted == false).FirstOrDefault();
                //int customCodeID = Convert.ToInt16(objCustomCode.RecordID);
                //if (customCodeID > 0)
                //{
                //  //  customCode = GenericFactory_EF_SalPIMaster.getCustomCode(customCodeID, DateTime.Now, itemMaster.CompanyID, 1, 1);
                //    customCode = GFactory_EF_CmnCustomCode.getCustomCode(customCodeID, DateTime.Now, 0, 1, 1);
                //}
                //else
                //{
                //    customCode = NextId.ToString();
                //}
                //.........END for custom code............ //

                #endregion CustomCode And Primary Key  Process
                #region Basic Save
                Hashtable ht = new Hashtable();
                ht.Add("CompanyID", model.CompanyID);
                ht.Add("CustomCode", model.CustomCode);
                ht.Add("CompanyShortName", model.CompanyShortName);
                ht.Add("CompanyName", model.CompanyName);
                ht.Add("LoggedCompanyID", commonEntity.loggedCompnyID);
                ht.Add("LoggedUser", commonEntity.loggedUserID);

                //  ht.Add("StatusID", model.StatusID);
                string spQuery = "[Set_CmnCompany]";
                result = GenericFactoryFor_Company.ExecuteCommand(spQuery, ht);
                #endregion Basic Save

                #region WorkFlow Transaction Entry
                ////  CHECK WorkFLow Setup
                ////IF targetUserID=0 Then Work flow is not configured
                //int targetUserID = new WorkFLowMgt().GetWorkFlowBeginner(commonEntity);
                //if (targetUserID > 0)
                //{
                //    //IN CASE OF SAVE
                //    //REQUIRD MENUID, COMPANYID, TARGET USERID AS TARGET USERID, USER AS CURRENT USERID,TRANSACTION ID AS MASTERID(INSERTED) ,STATUSID 1
                //    //IS APPROVED 0, IS DELETE 0, IS UPDATE 0 , @APPROVALCUSTOMCODE = '',Is Declained=0
                //    var comment = "";
                //    var APPROVALCUSTOMCODE = string.Empty;
                //    //    int WorkFlowStatus = new WorkFLowMgt().ExecuteWorkFlowTransactionProcess(new WorkFLowMgt().SetProcedureParam(commonEntity, targetUserID, NextId, 0, comment, 0, 0, 1, "", 0));
                //    String MessageName = System.Enum.GetName(typeof(workFlowTranEnum_MessageName), (int)workFlowTranEnum_MessageName.Created);
                //    int WorkFlowStatus = new WorkFLowMgt().ExecuteWorkFlowTransactionProcess(new WorkFLowMgt().SetProcedureParam(commonEntity, targetUserID, NextId, (int)workFlowTranEnum_IsApproved.False, comment, (int)workFlowTranEnum_IsUpdate.False, (int)workFlowTranEnum_IsDelete.False, (int)workFlowTranEnum_Status.Active, APPROVALCUSTOMCODE, (int)workFlowTranEnum_IsDeclained.False, MessageName));

                //}
                #endregion WorkFlow Transaction Entry
                #region CustomCode And Primary Key  Process Update Process
                //Update Primary Key and Custom Code
                GenericFactoryEF_Company.updateMaxID("CmnCompany", Convert.ToInt64(NextId));
                //  GFactory_EF_CmnCustomCode.updateCustomCode(customCodeID, DateTime.Now, 0, 1, 1);
                #endregion  CustomCode And Primary Key  Process Update Process

                #region WorkFlow Transaction Entry Team
                int workflowID = 0;
                List <vmCmnWorkFlowMaster> listWorkFlow = new WorkFLowMgt().GetWorkFlowMasterListByMenu(commonEntity);
                foreach (vmCmnWorkFlowMaster item in listWorkFlow)
                {
                    int userTeamID = item.UserTeamID ?? 0;
                    if (new WorkFLowMgt().checkUserValidation(commonEntity.loggedUserID ?? 0, item.WorkFlowID) && userTeamID > 0)
                    {
                        item.WorkFlowTranCustomID = model.CompanyID;
                        workflowID = new WorkFLowMgt().ExecuteTransactionProcess(item, commonEntity);
                        //Mail Service
                    }
                    if (userTeamID == 0)
                    {
                        item.WorkFlowTranCustomID = model.CompanyID;
                        workflowID = new WorkFLowMgt().ExecuteTransactionProcess(item, commonEntity);
                    }
                }
                #endregion Workflow Transaction Enltry Team
            }
            catch (Exception)
            {
                throw new Exception();
            }

            return(result);
        }