Beispiel #1
0
        // ~~~ override methods

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public Object handleRequest(com.alipay.remoting.BizContext bizCtx, MultiInterestBaseRequestBody request) throws Exception
        public override object handleRequest(BizContext bizCtx, object request)
        {
            logger.LogWarning("Request received:" + request);
            if (bizCtx.RequestTimeout)
            {
                string errMsg = "Stop process in client biz thread, already timeout!";
                logger.LogWarning(errMsg);
                throw new Exception(errMsg);
            }

            if (request is RequestBodyC1)
            {
                Assert.Equal(typeof(RequestBodyC1), request.GetType());
                return(handleRequest(bizCtx, (RequestBodyC1)request));
            }
            else if (request is RequestBodyC2)
            {
                Assert.Equal(typeof(RequestBodyC2), request.GetType());
                return(handleRequest(bizCtx, (RequestBodyC2)request));
            }
            else
            {
                throw new Exception("RequestBody does not belong to defined interests !");
            }
        }
        /// <summary>
        /// 转发流程
        /// </summary>
        /// <param name="businessID">业务系统数据主键ID</param>
        /// <param name="currentUser">当前用户</param>
        /// <param name="approvalContent">审批意见</param>
        /// <param name="forwardUser">转发人员【完整的用户信息】</param>
        private string ForwardUser(string businessID, UserInfo currentUser, string approvalContent, List <UserInfo> forwardUser)
        {
            string          strResult = string.Empty;
            WorkflowContext workflow  = WFClientSDK.GetProcess(null, businessID, currentUser);

            if (workflow.StatusCode != 0)
            {
                strResult = workflow.LastException.Message;
                return(strResult);
            }

            BizContext bizContext = new BizContext();

            bizContext.NodeInstanceList     = workflow.NodeInstanceList;
            bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID;
            bizContext.BusinessID           = workflow.BusinessID;
            bizContext.ApprovalContent      = approvalContent;
            bizContext.CurrentUser          = currentUser;

            string strForwardUser = JsonConvert.SerializeObject(forwardUser);

            bizContext.ExtensionCommond = new Dictionary <string, string>();
            bizContext.ExtensionCommond["ForwardUser"] = strForwardUser;

            WorkflowContext result = WFClientSDK.ExecuteMethod("ForwardUser", bizContext);

            if (result.StatusCode != 0)
            {
                strResult = result.LastException.Message;
            }
            return(strResult);
        }
        /// <summary>
        /// 撤回流程
        /// </summary>
        /// <param name="businessID">业务系统数据主键ID</param>
        /// <param name="currentUser">当前用户</param>
        /// <param name="approvalContent">审批意见</param>
        public string UndoSubmit(string businessID, UserInfo currentUser, string approvalContent)
        {
            string          strResult = string.Empty;
            WorkflowContext workflow  = WFClientSDK.GetProcess(null, businessID, currentUser);

            if (workflow.StatusCode != 0)
            {
                strResult = workflow.LastException.Message;
                return(strResult);
            }

            BizContext bizContext = new BizContext();

            bizContext.NodeInstanceList     = workflow.NodeInstanceList;
            bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID;
            bizContext.BusinessID           = workflow.BusinessID;
            bizContext.ApprovalContent      = approvalContent;
            bizContext.CurrentUser          = currentUser;
            WorkflowContext result = WFClientSDK.ExecuteMethod("UndoSubmit", bizContext);

            if (result.StatusCode != 0)
            {
                strResult = result.LastException.Message;
            }
            return(strResult);
        }
 public InnerTask(AsyncServerUserProcessor outerInstance, BizContext bizCtx, AsyncContext asyncCtx, object request)
 {
     this.outerInstance = outerInstance;
     this.bizCtx        = bizCtx;
     this.asyncCtx      = asyncCtx;
     this.request       = request;
 }
Beispiel #5
0
        private object handleRequest(BizContext bizCtx, RequestBodyC2 request)
        {
            long?waittime = (long?)bizCtx.InvokeContext.get(InvokeContext.BOLT_PROCESS_WAIT_TIME);

            Assert.NotNull(waittime);
            if (logger.IsEnabled(LogLevel.Information))
            {
                logger.LogInformation("Client User processor process wait time {}", waittime);
            }

            processTimes(request);
            if (!delaySwitch)
            {
                return(RequestBodyC2.DEFAULT_CLIENT_RETURN_STR);
            }
            try
            {
                Thread.Sleep(delayMs);
            }
            catch (ThreadInterruptedException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            return(RequestBodyC2.DEFAULT_CLIENT_RETURN_STR);
        }
Beispiel #6
0
    /// <summary>
    /// 使用linq保存表单数据【根据formid判断来存储】
    /// </summary>
    protected override void SaveFormData()
    {
        var info = BizContext.ERP_ContractFinalAccount.FirstOrDefault(x => x.FormID == FormId);

        if (info == null)
        {
            info = new ERP_ContractFinalAccount()
            {
                FormID           = FormId,
                CreateTime       = DateTime.Now.ToString(),
                StartDeptId      = ddlDepartName.SelectedItem.Value,
                ErpFormId        = Request["erpFormId"],
                RelationContract = Request["erpPoId"],
                ErpFormType      = "POJS",
                ApproveResult    = "",
                ERPFormTitle     = Request["FormTitle"],
                ERPApproveLev    = int.Parse(Request["erpApproveLev"])
            };
            BizContext.ERP_ContractFinalAccount.InsertOnSubmit(info);
        }
        else
        {
            info.StartDeptId = ddlDepartName.SelectedItem.Value;
        }
        BizContext.SubmitChanges();
    }
Beispiel #7
0
        /// <summary>
        /// 获取流程信息
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="bizContext">业务系统BizContext</param>
        /// <returns></returns>
        internal static WorkflowContext GetProcess(Page page, BizContext bizContext)
        {
            string result = ExecuteMethod(AppSettingInfo.CONST_ExecuteMethod_GetProcess, AppSettingInfo.CONST_ExecuteMode_Zero, AppSettingInfo.CONST_WorkflowMethodVersion, bizContext);

            SDKHelper.ShowProcess(page, result);
            return(JsonConvert.DeserializeObject <WorkflowContext>(result));
        }
Beispiel #8
0
    protected override void SaveFormData()
    {
        try
        {
            var info = BizContext.OA_ITSupport_Form.FirstOrDefault(x => x.FormID == FormId);
            if (info == null)
            {
                info = new OA_ITSupport_Form()
                {
                    FormID      = FormId,
                    CompanyName = tbCompany.Text,
                    Email       = tbEmail.Text,
                    DateTime    = DateTime.Now,
                    DeptCode    = _BPMContext.CurrentPWordUser.DepartCode,
                    DeptName    = _BPMContext.CurrentPWordUser.DepartName,
                    Mobile      = tbPhone.Text,
                    UserName    = _BPMContext.CurrentPWordUser.EmployeeName
                };
                BizContext.OA_ITSupport_Form.InsertOnSubmit(info);
            }

            info.STypeId    = int.Parse(ddlTypes.SelectedValue);
            info.QuestionId = int.Parse(ddlQuestions.SelectedValue);
            info.ContentTxt = tbContent.Text;
            info.Title      = GetFormTitle();


            BizContext.SubmitChanges();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Beispiel #9
0
 private void CheckIsModified(bool value)
 {
     if (value)
     {
         IsModified = true;
     }
     else
     {
         BizContext context = BizContext.Instance;
         Category   root    = context.Categories.FirstOrDefault();
         if (root != null)
         {
             if (root.NestedPasswords.Any(p => p.IsModified))
             {
                 IsModified = true;
                 return;
             }
             if (IsNestedTemplateModified(root))
             {
                 IsModified = true;
                 return;
             }
         }
         IsModified = false;
     }
 }
Beispiel #10
0
    /// <summary>
    /// 流程成功启动后操作
    /// </summary>
    protected override bool AfterWorkflowStart(int wfInstanceId)
    {
        string stepId = Guid.NewGuid().ToString();

        BizContext.OA_ITSupport_Step.InsertOnSubmit(new OA_ITSupport_Step()
        {
            Id             = stepId,
            FormID         = FormId,
            InstanceId     = _BPMContext.ProcID,
            StartTime      = DateTime.Now,
            StartType      = (int)ITSupportStatus.待领取,
            OrderId        = 1,
            ProcessGroupId = BizContext.V_ITSupport_Catalog.FirstOrDefault(x => x.Id.ToString() == ddlTypes.SelectedValue).GroupId.Value.ToString()
        });
        foreach (var item in ITSupportCommon.GetUserListByType(ddlTypes.SelectedValue))
        {
            BizContext.OA_ITSupport_Step_Users.InsertOnSubmit(new OA_ITSupport_Step_Users()
            {
                StepId    = stepId,
                UserCode  = item.EmployeeCode,
                LoginName = item.LoginName
            });
            NotifyToUser(item.LoginName);
        }
        var formInfo = BizContext.OA_ITSupport_Form.FirstOrDefault(x => x.FormID == FormId);

        if (formInfo != null)
        {
            formInfo.CurrentStepId  = stepId;
            formInfo.ProcessGroupId = BizContext.V_ITSupport_Catalog.FirstOrDefault(x => x.Id.ToString() == ddlTypes.SelectedValue).GroupId.Value.ToString();
        }

        BizContext.SubmitChanges();
        return(true);
    }
Beispiel #11
0
    /// <summary>
    /// 保存数据
    /// </summary>
    protected override void SaveFormData()
    {
        var info = BizContext.OA_InstructionOfWY.FirstOrDefault(x => x.FormID == FormId);

        if (info == null)
        {
            info = new OA_InstructionOfWY()
            {
                FormID          = FormId,
                DeptCode        = ddlDepartName.SelectedItem.Value.ToString(),
                DeptName        = ddlDepartName.SelectedItem.Text,
                UserName        = tbMobile.Text,
                DateTime        = tbDateTime.Text,
                Mobile          = tbMobile.Text,
                IsReportToWY    = cblIsReportToWY.SelectedIndex.ToString(),
                IsReportToGroup = cblIsReportToGroup.SelectedIndex.ToString(),
                Title           = tbTitle.Text,
                Content         = tbContent.Text,
                SecurityLevel   = cblSecurityLevel.SelectedIndex.ToString(),
                UrgenLevel      = cblUrgenLevel.SelectedIndex.ToString(),
                RelatedFormID   = string.Empty,

                LeadersSelected = SaveLeadersSelected(),
            };
            BizContext.OA_InstructionOfWY.InsertOnSubmit(info);
        }
        BizContext.SubmitChanges();
    }
        public JsonResult DisplayFirmInformation()
        {
            var Value = "";

            try
            {
                BizContext = (BizContext)Session["GBAdminBizContext"];
                int id = Convert.ToInt32(BizContext.FirmID);
                Session["GBAdminBizContext"] = BizContext;
                FirmInformationRepository objupdate = new FirmInformationRepository();
                var i = objupdate.GetFirmInfo(id);
                Value = Convert.ToString(i);
            }
            catch(Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }

            return Json(Value, JsonRequestBehavior.AllowGet);
        }
Beispiel #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public Object handleRequest(com.alipay.remoting.BizContext bizCtx, com.alipay.remoting.rpc.common.RequestBody request) throws Exception
        public override object  handleRequest(BizContext bizCtx, object request)
        {
            string threadName = Thread.CurrentThread.Name;

            Assert.Contains("Rpc-specific1-executor", threadName);

            logger.LogWarning("Request received:" + request);
            Assert.Equal(typeof(RequestBody), request.GetType());

            long waittime = ((long?)bizCtx.InvokeContext.get(InvokeContext.BOLT_PROCESS_WAIT_TIME)).Value;

            logger.LogWarning("Client User processor process wait time [" + waittime + "].");

            invokeTimes.incrementAndGet();
            if (!delaySwitch)
            {
                return(RequestBody.DEFAULT_CLIENT_RETURN_STR);
            }
            try
            {
                Thread.Sleep(delayMs);
            }
            catch (ThreadInterruptedException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            return(RequestBody.DEFAULT_CLIENT_RETURN_STR);
        }
        public ActionResult FirmInformation()
        {
            Session["PageName"] = "Finance";
            try
            {
                BizContext = (BizContext)Session["GBAdminBizContext"];
                int id = Convert.ToInt32(BizContext.FirmID);
                Session["GBAdminBizContext"] = BizContext;
                //  long id = 100003;

                FirmInformationRepository objupdate = new FirmInformationRepository();
                var Firm = objupdate.GetFirmInfo(id).FirstOrDefault(f => f.ID == id);
                SecurityUtils.SetGlobalViewbags(this, ActiveMenu, BizContext.UserContext.IsAdmin(), BizContext.UserContext.IsHotelAdmin(), BizContext.HotelID);
                return View(Firm);
            }
            catch(Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }
        }
Beispiel #15
0
        public override object  handleRequest(BizContext bizCtx, object request)
        {
            string threadName = Thread.CurrentThread.Name;

            //Assert.Contains("Rpc-netty-server-worker", threadName);

            logger.LogWarning("Request received:" + request);
            this.remoteAddr = bizCtx.RemoteAddress;

            long waittime = ((long?)bizCtx.InvokeContext.get(InvokeContext.BOLT_PROCESS_WAIT_TIME)).Value;

            logger.LogWarning("Server User processor process wait time [" + waittime + "].");

            if (!latch.IsSet)
            {
                latch.Signal();
            }
            logger.LogWarning("Server User processor say, remote address is [" + this.remoteAddr + "].");
            Assert.Equal(typeof(RequestBody), request.GetType());
            processTimes((RequestBody)request);
            if (!delaySwitch)
            {
                return(RequestBody.DEFAULT_SERVER_RETURN_STR);
            }
            try
            {
                Thread.Sleep(delayMs);
            }
            catch (ThreadInterruptedException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            return(RequestBody.DEFAULT_SERVER_RETURN_STR);
        }
        /// <summary>
        /// 提交审批(当最后的节点是同一个的时候,会有错误)
        /// </summary>
        /// <param name="businessID"></param>
        /// <param name="currentUser"></param>
        /// <param name="approvalContent"></param>
        /// <returns></returns>
        public virtual string SubmitProcess(string businessID, UserInfo currentUser, string approvalContent)
        {
            string          strResult = string.Empty;
            WorkflowContext workflow  = WFClientSDK.GetProcess(null, businessID, currentUser);

            if (workflow.StatusCode != 0)
            {
                throw workflow.LastException;
            }
            if (workflow.ProcessInstance.Status == 2)
            {
                strResult = "请到pc端发起流程!";
            }
            if (string.IsNullOrEmpty(strResult))
            {
                BizContext bizContext = new BizContext();
                bizContext.NodeInstanceList     = workflow.NodeInstanceList;
                bizContext.CcNodeInstanceList   = workflow.CcNodeInstanceList;
                bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID;
                bizContext.BusinessID           = workflow.BusinessID;
                bizContext.ApprovalContent      = approvalContent;
                bizContext.CurrentUser          = currentUser;
                WorkflowContext result = WFClientSDK.ExecuteMethod("SubmitProcess", bizContext);
                if (result.StatusCode != 0)
                {
                    strResult = result.LastException.Message;
                }
            }

            return(strResult);
        }
Beispiel #17
0
    protected void SaveFormData()
    {
        if (K2_TaskItem.ActivityInstanceDestination.Name == "员工意见")
        {
            var info = BizContext.HR_EmployeeRegular.FirstOrDefault(x => x.FormID == FormId);

            if (info != null)
            {
                info.Post        = tbPost.Text;
                info.Achievement = tbAchievement.Text;
                info.Sign        = tbSign.Text;
                info.SignDate    = tbSignDate.Value;
            }
            BizContext.SubmitChanges();
        }

        if (K2_TaskItem.ActivityInstanceDestination.Name == "用人部门意见")
        {
            var info = BizContext.HR_EmployeeRegular.FirstOrDefault(x => x.FormID == FormId);

            if (info != null)
            {
                info.WorkCompletion   = ddlWorkCompletion.SelectedValue;
                info.Advantage        = tbAdvantage.Text;
                info.Disadvantage     = tbDisadvantage.Text;
                info.Suggest          = tbSuggest.Text;
                info.QualityScore     = tbQualityScore.Text;
                info.AchievementScore = tbAchievementScore.Text;
                info.TatolScore       = SumScore();
                info.IsAgreeRegular   = ddlIsAgreeRegular.SelectedValue;
            }
            BizContext.SubmitChanges();
        }
    }
        public JsonResult DailyPropertyStatistics(string HitCountPeriodID, string StartDate, string EndDate)
        {
            //DateTime dt = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            //DateTime dt1 = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            //string Datefromm = Convert.ToString(dt);
            //string Datetoo = Convert.ToString(dt1);
            //string Datefromm = dt.ToString("yyyy-MM-dd");
            //string Datetoo = dt1.ToString("yyyy-MM-dd");
            string startdate = dateconvert(StartDate);
            string Enddate = dateconvert(EndDate);
            var PartID = "1";
            //string HotelID = Convert.ToString(Session["GBAdminBizContext"]);
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int HotelID = BizContext.HotelID;
            Session["GBAdminBizContext"] = BizContext;

            DataTable dts = new DataTable();
            PropertyStatisticsRepository objupdate = new PropertyStatisticsRepository();
            List<PropertyStatisticsExt> list = new List<PropertyStatisticsExt>();
            try{
            dts = objupdate.DisplaydatewisePropertyStatistics(PartID, HitCountPeriodID, startdate, Enddate, HotelID);
            if (dts != null)
            {
                if (dts.Rows.Count > 0)
                {
                    foreach (DataRow dr in dts.Rows)
                    {
                        PropertyStatisticsExt FirmObj = new PropertyStatisticsExt();
                        FirmObj.PartID = dr["PartID"].ToString();
                        FirmObj.RecordID = dr["RecordID"].ToString();
                        FirmObj.ReservationCount = dr["ReservationCount"].ToString();
                        FirmObj.Date = dr["Date"].ToString();
                        FirmObj.HitCount = dr["HitCount"].ToString();
                        FirmObj.Month = dr["Month"].ToString();
                        FirmObj.MonthName = dr["MonthName"].ToString();
                        FirmObj.Day = dr["Day"].ToString();
                        FirmObj.DayName = dr["DayName"].ToString();
                        list.Add(FirmObj);
                    }
                }
            }
            }
            catch (Exception ex)
               {
               string hostName1 = Dns.GetHostName();
               string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
               string PageName = Convert.ToString(Session["PageName"]);
               //string GetUserIPAddress = GetUserIPAddress1();
               using (BaseRepository baseRepo = new BaseRepository())
               {
                   //BizContext BizContext1 = new BizContext();
                   BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
               }
               Session["PageName"] = "";
               string error = ErrorHandling.HandleException(ex);
               return this.Json(new DataSourceResult { Errors = error });
               }
            return Json(list, JsonRequestBehavior.AllowGet);
        }
 public JsonResult GetAccomodationByID()
 {
     BizContext = (BizContext)Session["GBAdminBizContext"];
      int id = BizContext.HotelAccommodationTypeID;
      Session["GBAdminBizContext"] = BizContext;
      DropDownListsRepository model = new DropDownListsRepository();
      return Json(model.GetTypeHotelAccommodationByID(id).OrderBy(o => o.Name).Select(c => new { ID = c.ID, Name = c.Name }).OrderBy(o => o.Name), JsonRequestBehavior.AllowGet);
 }
 public void AssignBizContext()
 {
     if (Session["GBAdminBizContext"] != null)
     {
         BizContext = (BizContext)Session["GBAdminBizContext"];
     }
     Session["GBAdminBizContext"] = BizContext;
 }
Beispiel #21
0
 private void LoadData(string connectionString)
 {
     BizContext.OpenConnection(connectionString);
     RefreshData();
     InitialShow();
     connectionString = "";
     SelectedNode     = BizContext.Instance.RootCategory;
 }
Beispiel #22
0
    private void SaveData()
    {
        var info = BizContext.HR_EmployeeLeft.FirstOrDefault(x => x.FormID == FormId);

        info.Handover  = tbHandover.Text;
        info.Recipient = tbRecipient.Text;

        BizContext.SubmitChanges();
    }
Beispiel #23
0
    protected void SaveFormData()
    {
        var info = BizContext.HR_EmployeeTransfer.FirstOrDefault(x => x.FormID == FormId);

        if (info != null)
        {
            info.TransferReason = cblTransferReason.SelectedValue;
        }
        BizContext.SubmitChanges();
    }
Beispiel #24
0
        /// <summary>
        /// 执行流程动作
        /// </summary>
        /// <param name="methodName">操作命令</param>
        /// <param name="bizContext">业务系统上下文</param>
        /// <returns>执行流程后返回的流程信息</returns>
        public static WorkflowContext ExecuteMethod(string methodName, BizContext bizContext)
        {
            if (string.IsNullOrEmpty(methodName))
            {
                throw new Exception("操作命令不能为空");
            }
            string result = WFClientProcess.ExecuteMethod(methodName, 0, AppSettingInfo.CONST_WorkflowMethodVersion, bizContext);

            return(JsonConvert.DeserializeObject <WorkflowContext>(result));
        }
    protected override bool AfterWorkflowApproval(string action, string option, bool isSuccess)
    {
        if (isSuccess)
        {
            ///对于加签
            if (action == "提交")
            {
                return(true);
            }

            ///更新当前步骤审批人处理记录
            var currentStep = SysContext.WF_Custom_InstanceItems.FirstOrDefault(x => x.StepID == CurrentStep);
            List <CustomWorkflowUserInfo> userinfos = currentStep.PartUsers.ToUserList();
            var currentParter = userinfos.FirstOrDefault(x => x.UserInfo.LoginName == _BPMContext.CurrentUser.LoginId);
            if (currentParter != null)
            {
                currentParter.IsApproval = true;
                currentStep.PartUsers    = userinfos.ToXml();
                SysContext.SubmitChanges();
            }

            if (userinfos.Count(x => !x.IsApproval) == 0)
            {
                //本步骤所有人已经执行审批

                ///更新当前自定义实例步骤
                if (action == "同意")
                {
                    var list       = CustomWorkflowDataProcess.GetWorkItemsData(_BPMContext.ProcID, FormId);
                    var nextInfo   = list.Where(x => x.StepID > CurrentStep && !string.IsNullOrEmpty(x.PartUsers)).OrderBy(x => x.OrderId).FirstOrDefault();
                    var updateInfo = BizContext.OA_CustomWorkFlowInstance.FirstOrDefault(x => x.FormID == FormId);
                    if (nextInfo != null)
                    {
                        updateInfo.CurrentStepId = nextInfo.StepID;
                    }
                    else
                    {
                        updateInfo.CurrentStepId = -1;//没有后续节点,流程结束
                    }
                    BizContext.SubmitChanges();
                }
                else
                {
                    var updateInfo = BizContext.OA_CustomWorkFlowInstance.FirstOrDefault(x => x.FormID == FormId);

                    updateInfo.CurrentStepId = -1;//不同意,流程结束

                    BizContext.SubmitChanges();
                }
            }
        }


        return(true);
    }
        private BizContext GetBizContext()
        {
            var tokenHandler = new MemoryTokenHandler();
            var bizContext   = new BizContext(new SpConfiguration()
            {
                MaxLoginTryTimes = 10
            });

            bizContext.TokenHandler = tokenHandler;
            return(bizContext);
        }
Beispiel #27
0
 protected override void OnPreLoad(EventArgs e)
 {
     base.OnPreLoad(e);
     if (_BPMContext.ProcInst != null)
     {
         FormId      = _BPMContext.ProcInst.FormId;
         StartDeptId = _BPMContext.ProcInst.StartDeptCode;
         T formInfo = BizContext.GetTable <T>().FirstOrDefault();// x => x.FormId =
         InitFormData();
     }
 }
        public JsonResult GetReviews1()
        {
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int HotelID = BizContext.HotelID; ;
            int HotelID1 = Convert.ToInt32(Session["HotelID"]);
            PropertyReviewRepository modelRepo = new PropertyReviewRepository();

            var PropertyReviews = modelRepo.GetReviews1(HotelID);

            return Json(PropertyReviews, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 提交流程
        /// </summary>
        /// <param name="businessID"></param>
        /// <param name="currentUser"></param>
        /// <param name="approvalContent"></param>
        public bool SubmitProcess(string businessID, UserInfo currentUser, string approvalContent, out string Msg)
        {
            bool            blResult  = false;
            string          strResult = string.Empty;
            WorkflowContext workflow  = WFClientSDK.GetProcess(null, businessID, currentUser);


            B_MonthlyReportAction BRA1 = new B_MonthlyReportAction();

            BRA1.Action          = " 进入 MobileServiceBase.SubmitProcess :businessID:" + businessID;
            BRA1.Description     = "workflow.StatusCode : " + workflow.StatusCode + "; workflow.ProcessInstance.Status :" + workflow.ProcessInstance.Status.ToString();
            BRA1.Operator        = "MonthlyApprovalService.SubmitProcess";
            BRA1.OperatorTime    = DateTime.Now;
            BRA1.CreatorName     = currentUser.UserLoginID;
            BRA1.MonthlyReportID = businessID.ToGuid();
            BRA1.IsDeleted       = true;
            B_MonthlyReportActionOperator.Instance.AddMonthlyReportAction(BRA1);

            if (workflow.StatusCode != 0)
            {
                throw workflow.LastException;
            }
            if (workflow.ProcessInstance.Status == 2)
            {
                strResult = "请到pc端发起流程!";
            }
            if (string.IsNullOrEmpty(strResult))
            {
                BizContext bizContext = new BizContext();
                bizContext.NodeInstanceList     = workflow.NodeInstanceList;
                bizContext.CcNodeInstanceList   = workflow.CcNodeInstanceList;
                bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID;
                bizContext.BusinessID           = workflow.BusinessID;
                bizContext.ApprovalContent      = approvalContent;
                bizContext.CurrentUser          = currentUser;
                WorkflowContext result = WFClientSDK.ExecuteMethod("SubmitProcess", bizContext);

                blResult = CanApproveBusinessData(result);



                BRA1.Action          = "MobileServiceBase.SubmitProcess 结束 :businessID:" + businessID;
                BRA1.Description     = "strResult : " + strResult + "; blResult :" + blResult.ToString();
                BRA1.Operator        = "MonthlyApprovalService.SubmitProcess";
                BRA1.OperatorTime    = DateTime.Now;
                BRA1.MonthlyReportID = businessID.ToGuid();
                BRA1.CreatorName     = currentUser.UserLoginID;
                BRA1.IsDeleted       = true;
                B_MonthlyReportActionOperator.Instance.AddMonthlyReportAction(BRA1);
            }
            Msg = strResult;
            return(blResult);
        }
Beispiel #30
0
    /// <summary>
    /// 使用linq保存表单数据【根据formid判断来存储】
    /// </summary>
    protected override void SaveFormData()
    {
        var info = BizContext.OA_ContractOfWY.FirstOrDefault(x => x.FormID == FormId);

        if (info == null)
        {
            info = new OA_ContractOfWY()
            {
                FormID        = FormId,
                SecurityLevel = cblSecurityLevel.SelectedIndex.ToString(),
                UrgenLevel    = cblUrgenLevel.SelectedIndex.ToString(),

                DeptCode = ddlDepartName.SelectedItem.Value.ToString(),
                DeptName = ddlDepartName.SelectedItem.Text,
                DateTime = DateTime.Now.ToString(),
                UserName = tbUserName.Text,
                Mobile   = tbMobile.Text,

                IsReportToWY    = cblIsReportToWY.SelectedIndex.ToString(),
                IsReportToGroup = cblIsReportToGroup.SelectedIndex.ToString(),
                //新添加的存储数据
                //合同类型
                ContractType1 = ddlContractType1.SelectedItem.Value,
                ContractType2 = ddlContractType2.SelectedItem != null ? ddlContractType2.SelectedItem.Value : "",
                ContractType3 = ddlContractType3.SelectedItem != null ? ddlContractType3.SelectedItem.Value : "",

                ContractTypeName1 = ddlContractType1.SelectedItem.Text,
                ContractTypeName2 = ddlContractType2.SelectedItem != null ? ddlContractType2.SelectedItem.Text : "",
                ContractTypeName3 = ddlContractType3.SelectedItem != null ? ddlContractType3.SelectedItem.Text : "",

                ContractSum = tbContractSum.Text,

                IsSupplementProtocol     = cblIsSupplementProtocol.SelectedValue.ToString(),
                IsSupplementProtocolText = tbSupplementProtocol.Text,
                IsFormatContract         = cblIsFormatContract.SelectedValue.ToString(),
                IsNormText = cblIsNormText.SelectedValue.ToString(),
                IsBidding  = cblIsBidding.SelectedValue.ToString(),
                //合同主体
                ContractSubject      = ddlContractSubject.SelectedItem.Value,
                ContractSubjectName  = ddlContractSubject.SelectedItem.Text,
                ContractSubjectName2 = tbContractSubject1.Text,
                ContractSubjectName3 = tbContractSubject2.Text,
                ContractSubjectName4 = tbContractSubject3.Text,

                ContractTitle   = tbContractTitle.Text,
                ContractContent = tbContractContent.Text,
                LeadersSelected = SaveLeadersSelected(),
                RelatedFormID   = string.Empty,
            };
            BizContext.OA_ContractOfWY.InsertOnSubmit(info);
        }
        BizContext.SubmitChanges();
    }
Beispiel #31
0
        /// <summary>
        /// 将发起参数WFStartupParameter转换为BizContext
        /// </summary>
        /// <param name="startup"></param>
        /// <returns>BizContext</returns>
        private static BizContext ConvertToBizContext(WFStartupParameter startup)
        {
            BizContext bizContext = new BizContext();

            bizContext.FormParams          = startup.FormParams;
            bizContext.DynamicRoleUserList = startup.DynamicRoleUserList;
            bizContext.FlowCode            = startup.FlowCode;
            bizContext.ProcessMobileURL    = startup.ProcessMobileURL;
            bizContext.ProcessTitle        = startup.ProcessTitle;
            bizContext.ProcessURL          = startup.ProcessURL;
            bizContext.CurrentUser         = startup.CurrentUser;
            return(bizContext);
        }
Beispiel #32
0
        private static XmlPassword[] GetPasswords()
        {
            BizContext context = BizContext.Instance;

            return(context.Categories.FirstOrDefault().NestedPasswords.Select(p => new XmlPassword
            {
                Name = p.Name,
                Category = p.Category.GetPath(2),
                Fields = p.Fields.Where(f => f.Type != FieldType.Separator).Select(f => new XmlField {
                    Name = f.Name, Value = f.StringValue, Type = f.Type.ToString()
                }).ToArray()
            }).ToArray());
        }
Beispiel #33
0
        /// <summary>
        /// 获取流程WorkflowContext对象(加载已有流程信息)
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="businessID">业务ID</param>
        /// <param name="userLoginID">用户CTX账号</param>
        /// <returns>流程信息</returns>
        public static WorkflowContext GetProcess(Page page, string businessID, string userLoginID = null)
        {
            BizContext bizContext = new BizContext();

            bizContext.BusinessID = businessID;
            if (!string.IsNullOrEmpty(userLoginID))
            {
                bizContext.CurrentUser = new UserInfo()
                {
                    UserLoginID = userLoginID
                };
            }
            return(WFClientProcess.GetProcess(page, bizContext));
        }
Beispiel #34
0
        public override object handleRequest(BizContext bizCtx, object request)
        {
            logger.LogWarning("Request received:" + request);
            invokeTimes.incrementAndGet();

            long waittime = ((long?)bizCtx.InvokeContext.get(InvokeContext.BOLT_PROCESS_WAIT_TIME)).Value;

            logger.LogWarning("PreHandleUserProcessor User processor process wait time [" + waittime + "].");

            Assert.Equal(typeof(RequestBody), request.GetType());
            Assert.Equal(IPAddress.Loopback.MapToIPv6().ToString(), bizCtx.RemoteHost);
            Assert.True(bizCtx.RemotePort != -1);
            return(bizCtx.get("test"));
        }
Beispiel #35
0
    protected override void SaveFormData()
    {
        var info = BizContext.HR_EmployeeNeed.FirstOrDefault(x => x.FormID == FormId);

        if (info == null)
        {
            info = new HR_EmployeeNeed()
            {
                FormID              = FormId,
                DateTime            = UpdatedTextBox.Value,
                DeptName            = ddlDeptName.SelectedItem.Text,
                DeptCode            = ddlDeptName.SelectedItem.Value.ToString(),
                Position            = tbPosition.Text,
                Number              = tbNumber.Text,
                Reason              = ddlReason.SelectedItem.Text,
                MajorDuty           = tbMajorDuty.Text,
                Sex                 = ddlSex.SelectedItem.Text,
                Age                 = ddlAge.SelectedItem.Text,
                Education           = ddlEducation.SelectedItem.Text,
                Specialty           = ddlSpecialty.SelectedItem.Text,
                Title               = ddlTitle.SelectedItem.Text,
                WorkingLifetime     = ddlWorkingLifetime.SelectedItem.Text,
                WorkTime            = tbWorkTime.Value,
                ProfessionalAbility = tbProfessionalAbility.Text,
                IsGroup             = hfIsGroup.Value
            };
            BizContext.HR_EmployeeNeed.InsertOnSubmit(info);
        }
        else
        {
            info.DateTime            = UpdatedTextBox.Value;
            info.DeptName            = ddlDeptName.SelectedItem.Text;
            info.DeptCode            = ddlDeptName.SelectedItem.Value.ToString();
            info.Position            = tbPosition.Text;
            info.Number              = tbNumber.Text;
            info.Reason              = ddlReason.SelectedItem.Text;
            info.MajorDuty           = tbMajorDuty.Text;
            info.Sex                 = ddlSex.SelectedItem.Text;
            info.Age                 = ddlAge.SelectedItem.Text;
            info.Education           = ddlEducation.SelectedItem.Text;
            info.Specialty           = ddlSpecialty.SelectedItem.Text;
            info.Title               = ddlTitle.SelectedItem.Text;
            info.WorkingLifetime     = ddlWorkingLifetime.SelectedItem.Text;
            info.WorkTime            = tbWorkTime.Value;
            info.ProfessionalAbility = tbProfessionalAbility.Text;
        }
        BizContext.SubmitChanges();
    }
Beispiel #36
0
    protected override void SaveFormData()
    {
        var info = BizContext.HR_SalaryAdjust.FirstOrDefault(x => x.FormID == FormId);

        if (info == null)
        {
            info = new HR_SalaryAdjust()
            {
                FormID          = FormId,
                AnnualSalary    = tbAnnualSalary.Text,
                DeptName        = tbDeptName.Text,
                EffectiveDate   = tbEffectiveDate.Value,
                Post            = tbPost.Text,
                Ratio           = tbRatio.Text,
                Reason          = tbReason.Text,
                Salary          = tbSalary.Text,
                ToAnnualSalary  = tbToAnnualSalary.Text,
                ToDeptName      = tbToDeptName.Text,
                ToPost          = tbToPost.Text,
                ToRatio         = tbToRatio.Text,
                ToSalary        = tbToSalary.Text,
                UserName        = tbUserName.Text,
                WorkPlace       = tbWorkPlace.Text,
                LeadersSelected = SaveApproveList(),
                IsGroup         = hfIsGroup.Value
            };
            BizContext.HR_SalaryAdjust.InsertOnSubmit(info);
        }
        else
        {
            info.AnnualSalary    = tbAnnualSalary.Text;
            info.DeptName        = tbDeptName.Text;
            info.EffectiveDate   = tbEffectiveDate.Value;
            info.Post            = tbPost.Text;
            info.Ratio           = tbRatio.Text;
            info.Reason          = tbReason.Text;
            info.Salary          = tbSalary.Text;
            info.ToAnnualSalary  = tbToAnnualSalary.Text;
            info.ToDeptName      = tbToDeptName.Text;
            info.ToPost          = tbToPost.Text;
            info.ToRatio         = tbToRatio.Text;
            info.ToSalary        = tbToSalary.Text;
            info.UserName        = tbUserName.Text;
            info.WorkPlace       = tbWorkPlace.Text;
            info.LeadersSelected = SaveApproveList();
        }
        BizContext.SubmitChanges();
    }
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            //  string CurrentCulture_TwoLetter = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            if (requestContext.HttpContext.Session["GBAdminBizContext"] != null)
            {
                BizContext = (BizContext)requestContext.HttpContext.Session["GBAdminBizContext"];
            }
            //string Nameax = ReturnSyatemCulture();
            string SelectedLanguage = "en-Gb";
            if (BizContext.SystemCultureCode != null)
            {
                SelectedLanguage = BizContext.SystemCultureCode;
            }

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(SelectedLanguage);
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(SelectedLanguage);

            base.Initialize(requestContext);

            if (SelectedLanguage != "en-Gb")
            {
                try
                {
                    CultureInfo TempCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
                    TempCulture.DateTimeFormat.Calendar = System.Globalization.CultureInfo.GetCultureInfo("en-Gb").DateTimeFormat.Calendar;
                    TempCulture.NumberFormat.NumberDecimalSeparator = ".";
                    System.Threading.Thread.CurrentThread.CurrentCulture = TempCulture;
                    CultureInfo TempCulture1 = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentUICulture.Clone();
                    TempCulture1.DateTimeFormat.Calendar = System.Globalization.CultureInfo.GetCultureInfo("en-Gb").DateTimeFormat.Calendar;
                    TempCulture1.NumberFormat.NumberDecimalSeparator = ".";
                    System.Threading.Thread.CurrentThread.CurrentUICulture = TempCulture1;
                }
                catch
                {
                }

                //base.Initialize(requestContext);
            }
        }
        //public JsonResult LoadHotelAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay)
        //{
        //    int i = 1;
        //    int RoomID = Convert.ToInt32(RoomType);
        //    BizContext = (BizContext)Session["GBAdminBizContext"];
        //    int Hotelid = BizContext.HotelID;
        //    Session["GBAdminBizContext"] = BizContext;
        //    RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository();
        //    var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID);
        //    int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms);
        //    ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms);
        //    ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy);
        //    // ObjRep.Getdates(StartDate, Enddate, WeekDay);
        //    //ObjRep.GetHotelAvailability(Hotelid,StartDate, Enddate);
        //    //ObjRep.GetHotelRate(Hotelid, StartDate, Enddate, AccommodationType, PricePolicy);
        //    return Json(ObjRep.Getdates(StartDate, Enddate, WeekDay), JsonRequestBehavior.AllowGet);
        //}
        //public string ConvertToDateTime(string strDateTime)
        //{
        //    DateTime dtFinaldate;
        //    string sDateTime;
        //    dtFinaldate = Convert.ToDateTime(strDateTime);
        //        string[] sDate = strDateTime.Split('.');
        //        sDateTime = sDate[1] + '/' + sDate[0] + '/' + sDate[2];
        //        return sDateTime;
        //}
        public JsonResult LoadHotelAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay)
        {
            //if(CultureCode =="de-DE" || CultureCode=="ru-RU")
            //{

            //    DateTime dt = Convert.ToDateTime(StartDate);
            //    DateTime dt1 = Convert.ToDateTime(Enddate);
            //    string strDate = ConvertToDateTime(StartDate);
            //    StartDate = strDate;
            //    string Enddat = ConvertToDateTime(Enddate);
            //    Enddate = Enddat;
            //}

            int RoomID = 0;
            try
            {
                RoomID = Convert.ToInt32(RoomType);
            }
            catch
            {
                RoomID = 0;
            }
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int Hotelid= BizContext.HotelID;
            Session["GBAdminBizContext"] = BizContext;
            RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository();
            var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID);
            int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms);
            ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms);
            ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy);
            DataTable AvailabilityTable = ObjRep.GetHotelAvailability(Hotelid, StartDate, Enddate);
            DataTable RateTable = ObjRep.GetHotelRate(Hotelid, StartDate, Enddate, AccommodationType, PricePolicy);
            return Json(ObjRep.Getdates(StartDate, Enddate, WeekDay, AvailabilityTable, RateTable, Convert.ToInt32(RoomType), MaximamPeopleCount), JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetRoomsByHotel()
        {
            BizContext = (BizContext)Session["GBAdminBizContext"];
             int id = BizContext.HotelID;
             Session["GBAdminBizContext"] = BizContext;
             NewPromotionRepository model = new NewPromotionRepository();

             return Json(model.GetHotelRooms(id), JsonRequestBehavior.AllowGet);
        }
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            //  string CurrentCulture_TwoLetter = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            if (requestContext.HttpContext.Session["GBAdminBizContext"] != null)
            {
                BizContext = (BizContext)requestContext.HttpContext.Session["GBAdminBizContext"];
            }
            //string Nameax = ReturnSyatemCulture();
            string SelectedLanguage = "en-Gb";
            if (BizContext.SystemCultureCode != null)
            {
                SelectedLanguage = BizContext.SystemCultureCode;
            }

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(SelectedLanguage);
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(SelectedLanguage);

            base.Initialize(requestContext);
        }
        public JsonResult DisplaypageloadPropertyStatistics()
        {
            string HitCountPeriodID ="3";
            //DateTime startdate = DateTime.Now;
            ////DateTime dt1 = DateTime.ParseExact(startdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            //string Datefromm = "2015-11-16";
            //string Datetoo = startdate.ToString("yyyy-MM-dd");
            string Datefromm = DateTime.Now.ToString("yyyy-MM-dd");
            string Datetoo = DateTime.Now.AddDays(10).ToString("yyyy-MM-dd");
            string startdate = dateconvert(Datefromm);
            string Enddate = dateconvert(Datetoo);
            string PartID = "1";
            //string HotelID =Convert.ToString( Session["GBAdminBizContext"]);
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int HotelID = BizContext.HotelID;
            Session["GBAdminBizContext"] = BizContext;

            PropertyStatisticsRepository objupdate = new PropertyStatisticsRepository();
            var DailyStatistics = objupdate.DisplayPropertyStatistics(PartID, HitCountPeriodID, startdate, Enddate, HotelID);
            ViewBag.DailyStatistics = DailyStatistics;
            return Json(DailyStatistics, JsonRequestBehavior.AllowGet);
        }
        public ActionResult LogOn(LogOnModel model, string returnUrl, FormCollection formcollection)
        {
            // Decrypt128New("M5z8bP0bD/auyD/1wfthvCCkrr6q+quBRRRcyTGBh5c=");

            Home obj = new Home();

            ViewBag.AllCulture = obj.GetCulturecode();

            RemoveUserfromSession();
            string Msg = "";
            //Set Application Header with Application Type + Version and Build Date
            //  Session["ApplicationHeader"] = SecurityUtils.ApplicationHeader;
            if (returnUrl != null)
                if (returnUrl.Contains("%2f"))
                    returnUrl = Server.UrlDecode(returnUrl);
            bool locked = false;

            //string kjhgkhjk = model.Language;
            bool val = true;
            if (Request.QueryString["RemindCode"] != null)
            {
                string userID = "";
                string userName = "";
                string RemindCode = BizUtil.DecryptQueryStringParam(Request.QueryString["RemindCode"], ref val, true);
                bool checkDate = false;
                string[] tokens = RemindCode.Split(';');
                if (tokens.Length >= 3)
                {
                    userID = tokens[0];
                    userName = tokens[1];

                }

                if (RemindCode != "")
                {
                    using (BaseRepository baseRepo = new BaseRepository())
                    {
                        if (model.Password == model.ConfirmPassword)
                        {
                            BizContext BizContext = new BizContext();
                            if (userName != "" )
                            {
                                BizUser.UnlockUser(baseRepo.BizDB, "", userName);
                            }

                            BizUser.UpdateUserPassword(baseRepo.BizDB, userID, (new BizCrypto.AES128()).Encrypt(model.Password));
                            if (ValidateUser(model.UserName, model.Password, model.Language, ref locked, ref Msg))
                            {
                                if (!locked)
                                {
                                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                                    return RedirectToAction("Index", "Home");
                                }
                                else
                                {
                                    ModelState.AddModelError("", "Your cannot log on the System, because your status is Locked. Please contact your Department Administrator.");
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", Msg);
                        }
                    }
                }
            }

            if (ModelState.IsValid)
            {
                if (ValidateUser(model.UserName, model.Password, model.Language, ref locked, ref Msg))
                {
                    if (!locked)
                    {

                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

                        return RedirectToAction("Index", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Your cannot log on the System, because your status is Locked. Please contact your Department Administrator.");
                    }
                }
                else
                {
                    ModelState.AddModelError("", Msg);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        //
        // POST: /Account/LogOn
        //public string Decrypt128New(string Pass)
        //{
        //    //  string EncryptionKey = "MAKV2SPBNI99212";
        //    byte[] cipherBytes = Convert.FromBase64String(Pass);
        //    using (Aes encryptor = Aes.Create())
        //    {
        //        encryptor.Key = Encoding.UTF8.GetBytes("2428598755421637");
        //        encryptor.IV = Encoding.UTF8.GetBytes("5369523205842148");
        //        using (MemoryStream ms = new MemoryStream())
        //        {
        //            using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
        //            {
        //                cs.Write(cipherBytes, 0, cipherBytes.Length);
        //                cs.Close();
        //            }
        //            Pass = Encoding.Unicode.GetString(ms.ToArray());
        //        }
        //    }
        //    return Pass;
        //}
        //public string Encrypt(string clearText)
        //{
        //    byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
        //    using (Aes encryptor = Aes.Create())
        //    {
        //        encryptor.Key = Encoding.UTF8.GetBytes("2428598755421637");
        //        encryptor.IV = Encoding.UTF8.GetBytes("5369523205842148");
        //        using (MemoryStream ms = new MemoryStream())
        //        {
        //            using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
        //            {
        //                cs.Write(clearBytes, 0, clearBytes.Length);
        //                cs.Close();
        //            }
        //            clearText = Convert.ToBase64String(ms.ToArray());
        //        }
        //    }
        //    return clearText;
        //}
        //public ActionResult LogOn(LogOnModel model, string returnUrl, FormCollection formcollection)
        //{
        //    // Decrypt128New("M5z8bP0bD/auyD/1wfthvCCkrr6q+quBRRRcyTGBh5c=");
        //    Home obj = new Home();
        //    ViewBag.AllCulture = obj.GetCulturecode();
        //    RemoveUserfromSession();
        //    string Msg = "";
        //    //Set Application Header with Application Type + Version and Build Date
        //    //  Session["ApplicationHeader"] = SecurityUtils.ApplicationHeader;
        //    if (returnUrl != null)
        //        if (returnUrl.Contains("%2f"))
        //            returnUrl = Server.UrlDecode(returnUrl);
        //    bool locked = false;
        //    //string kjhgkhjk = model.Language;
        //    bool val = true;
        //    if (ModelState.IsValid)
        //    {
        //        if (ValidateUser(model.UserName, model.Password, model.Language, ref locked, ref Msg))
        //        {
        //            if (!locked)
        //            {
        //                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
        //                return RedirectToAction("Index", "Home");
        //            }
        //            else
        //            {
        //                ModelState.AddModelError("", "Your cannot log on the System, because your status is Locked. Please contact your Department Administrator.");
        //            }
        //        }
        //        else
        //        {
        //            ModelState.AddModelError("", Msg);
        //        }
        //    }
        //    // If we got this far, something failed, redisplay form
        //    return View(model);
        //}
        public ActionResult updatepassword(string Language, string UserName, string Password)
        {
            string status = "false";
            bool locked = false;
            string Msg = "";

            string ReminduserID = Convert.ToString(Session["RemindUserid"]);
            using (BaseRepository baseRepo = new BaseRepository())
            {
                bool RememberMe = true;
                BizContext BizContext = new BizContext();
                BizUser.UnlockUser(baseRepo.BizDB, "", UserName);
                BizUser.UpdateUserPassword(baseRepo.BizDB, ReminduserID, (new BizCrypto.AES128()).Encrypt(Password));
                if (ValidateUser(UserName, Password, Language, ref locked, ref Msg))
                {
                    if (!locked)
                    {
                        FormsAuthentication.SetAuthCookie(UserName, RememberMe);

                        //return RedirectToAction("Index", "Home");
                    }

                }

            }
            return RedirectToAction("Index", "Home");

            return View(status);
        }
        //*********The Following Method can be used if Authentication take place from custom users Table***********//
        public Boolean ValidateUser(string Username, string password, string UserLanguage, ref bool locked, ref string Msg)
        {
            Boolean status = false;

            using (BaseRepository baseRepo = new BaseRepository())
            {
                // BizContext bc = new BizContext();

                Business.BizTbl_User user = BizUser.GetUser(baseRepo.BizDB, string.Empty, Username, password);
                BizContext BizContext = new BizContext();
                // BizContext bc = new BizContext();
                UserContext uc = new UserContext();
                // BizApplication.GetBizContext(Username, password, CultureCode,ref bc);
                if (user != null)
                {
                    status = true;
                    BizApplication.SetUserContext(baseRepo.BizDB, ref uc, Convert.ToInt64(user.ID), CultureCode);
                    BizContext.UserContext = uc;

                        //if (uc.IsHotelAdmin()) {
                        //    System.Linq.IQueryable<Business.TB_Hotel> userHotels = BizHotel.GetHotels(baseRepo.BizDB, null, uc.FirmID, null, user.ID.ToString());
                        //    foreach (Business.TB_Hotel hotel in userHotels)
                        //    {
                        //        BizContext.Hotels.Add(hotel.ID, hotel.Name);
                        //    }
                        //    Business.TB_Hotel userHotel = userHotels.First();
                        //    BizContext.HotelID = userHotel.ID;
                        //    BizContext.HotelCountryID = userHotel.CountryID;
                        //    BizContext.HotelRegionID = Convert.ToInt64(userHotel.RegionID);
                        //    BizContext.HotelCityID = Convert.ToInt64(userHotel.CityID);
                        //    BizContext.HotelCurrencyID = Convert.ToString(userHotel.CurrencyID);
                        //   // BizContext.HotelCurrencyName = dc.GetColumn(GetCurrencies(dc, CultureCode, bc.HotelCurrencyID)(0), "Name");
                        //    BizContext.HotelAccommodationTypeID = userHotel.HotelAccommodationTypeID;
                        //    BizContext.HotelAvailabilityRateUpdate = Convert.ToBoolean(userHotel.AvailabilityRateUpdate);
                        //    BizContext.HotelRoutingName = userHotel.RoutingName;
                        //    BizContext.FirmID = Convert.ToString(userHotel.FirmID);
                        //    Session["SelectedHotelID"] = userHotel.ID;
                        //    Session["SelectedHotelName"] = userHotel.Name;
                        //}

                    if (BizContext.UserContext.IsHotelAdmin())
                    {

                       // System.Linq.IQueryable<Business.TB_Hotel> userHotels = BizHotel.GetHotels(baseRepo.BizDB, null, uc.FirmID, null, user.ID.ToString());
                        int i = 0;
                        baseRepo.SQLCon.Open();
                        DataTable dt = new DataTable();
                        SqlCommand cmd = new SqlCommand("B_Ex_GetUserHotelByUserID_TB_Hotel_SP", baseRepo.SQLCon);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@UserID", user.ID.ToString());
                        cmd.Parameters.AddWithValue("@FirmID", uc.FirmID);
                        SqlDataAdapter sda = new SqlDataAdapter(cmd);
                        sda.Fill(dt);
                        baseRepo.SQLCon.Close();
                        foreach (DataRow hotel in dt.Rows)
                        {
                            BizContext.Hotels.Add(Convert.ToInt32(hotel["ID"]), (hotel["Name"].ToString()));
                            if (i == 0)
                            {
                                BizContext.HotelID = Convert.ToInt32(hotel["ID"]);
                                BizContext.FirmID = hotel["FirmID"].ToString();
                                BizContext.HotelAccommodationTypeID = Convert.ToInt32(hotel["HotelAccommodationTypeID"]);
                                BizContext.HotelRoutingName = hotel["Name"].ToString();
                                Session["SelectedHotelID"] = Convert.ToInt32(hotel["ID"]);
                                Session["SelectedHotelName"] = hotel["Name"].ToString();
                            }
                            i++;
                        }
                    }
                    int userCountryID = 0;
                    //if (bc.UserContext.IPAddress == string.Empty)
                    //{
                    if (Session["GBAdminBizContext"] != null)
                    {
                        BizContext = (BizContext)Session["GBAdminBizContext"];
                    }
                    Session["GBAdminBizContext"] = BizContext;

                    if (UserLanguage != "")
                    {
                        try
                        {
                            string[] words = UserLanguage.Split(',');

                            BizContext.SystemCultureCode = words[1];
                            BizContext.CultureCode = words[0];
                            Session["CultureCode"] = words[0];
                            Session["GBAdminBizContext"] = BizContext;
                        }
                        catch
                        {
                            BizContext.SystemCultureCode = "en-GB";
                            BizContext.CultureCode = "en";
                            Session["GBAdminBizContext"] = BizContext;
                            Session["CultureCode"] = "en";
                        }

                    }
                    else
                    {
                        BizContext.SystemCultureCode = "en-GB";
                        BizContext.CultureCode = "en";
                        Session["GBAdminBizContext"] = BizContext;
                        Session["CultureCode"] = "en";
                    }

                    string userIpAddress = GetUserIPAddress();
                    //GetCultureByIpaddress(userIpAddress);
                    try
                    {
                        CountriesRepository countryRepo = new CountriesRepository();
                        Business.TB_Country userCountryInfo = BizApplication.GetCountryInfoFromIPAddress(baseRepo.BizDB, userIpAddress);

                        userCountryID = userCountryInfo.ID;
                    }
                    catch
                    {
                        userCountryID = 0;
                    }

                    // bc.UserContext.IPAddress = userIpAddress;
                    // }

                    //if (bc.UserSessionID == string.Empty)
                    //{
                    AuthenticationRepository authRepo = new AuthenticationRepository();
                    string countryID = (userCountryID == 0 ? String.Empty : userCountryID.ToString());
                    string UserSessionID = BizUser.SaveUserSession(baseRepo.BizDB, String.Empty, Guid.NewGuid().ToString(), user.ID.ToString(), countryID, userIpAddress, DateTime.Now.ToString()).ToString();
                    //}

                    if (Session["GBAdminBizContext"] != null)
                    {
                        BizContext = (BizContext)Session["GBAdminBizContext"];
                    }
                    BizContext.UserSessionID = UserSessionID;
                    Session["GBAdminBizContext"] = BizContext;

                    // Session[BizCommon.AdminBizContextName] = bc;
                    BizUser.AddUserOperation(baseRepo.BizDB, user.ID.ToString(), DateTime.Now.ToString(), BizCommon.Operation.Login, "", "", GetUserIPAddress(), UserSessionID);

                    Session["username"] = user.DisplayName;
                    Session["UserID"] = user.ID;
                }
                else
                {
                    Msg = Resources.Resources.CheckYourUserNameAndPasswordWarning; //BizMessage.GetMessage(baseRepo.BizDB, "CheckYourUserNameAndPasswordWarning", "en");
                }
            }

            return status;
        }
        public void GetCultureByIpaddress(string UserIP)
        {
            //UserIP = "5.11.79.255";
            using (BaseRepository baseRepo = new BaseRepository())
            {
                BizContext BizContext = new BizContext();
                try
                {

                    try
                    {
                        string url = "http://freegeoip.lwan.ws/json/" + UserIP.ToString();
                        WebClient client = new WebClient();
                        string jsonstring = client.DownloadString(url);
                        dynamic dynObj = JsonConvert.DeserializeObject(jsonstring);
                        // System.Web.HttpContext.Current.Session["LocId"] = dynObj.country_code;

                        string countryCode = dynObj.country_code;
                        Session["CountryCodeFromIP"] = countryCode;

                        DataTable Cultures = new DataTable();
                        baseRepo.SQLCon.Open();
                        SqlCommand cmd = new SqlCommand("B_GetCultureAvailableCount_BizTbl_Culture_SP", baseRepo.SQLCon);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@Culture", countryCode);
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.Fill(Cultures);
                        baseRepo.SQLCon.Close();

                        if (Cultures != null)
                        {
                            if (Cultures.Rows.Count > 0)
                            {
                                foreach (DataRow dr in Cultures.Rows)
                                {

                                    if (Session["GBAdminBizContext"] != null)
                                    {
                                        BizContext = (BizContext)Session["GBAdminBizContext"];
                                    }
                                    BizContext.SystemCultureCode = dr["SystemCode"].ToString();
                                    BizContext.CultureCode = dr["CultureCode"].ToString();
                                    Session["CultureCode"] = dr["CultureCode"].ToString();
                                    Session["GBAdminBizContext"] = BizContext;
                                }
                            }
                            else
                            {
                                if (Session["GBAdminBizContext"] != null)
                                {
                                    BizContext = (BizContext)Session["GBAdminBizContext"];
                                }
                                BizContext.SystemCultureCode = "en-Gb";
                                BizContext.CultureCode = "en";
                                Session["GBAdminBizContext"] = BizContext;
                                Session["CultureCode"] = "en";
                            }
                        }

                        else
                        {
                            if (Session["GBAdminBizContext"] != null)
                            {
                                BizContext = (BizContext)Session["GBAdminBizContext"];
                            }
                            BizContext.SystemCultureCode = "en-Gb";
                            BizContext.CultureCode = "en";
                            Session["GBAdminBizContext"] = BizContext;
                            Session["CultureCode"] = "en";
                        }

                    }
                    catch
                    {
                        if (Session["GBAdminBizContext"] != null)
                        {
                            BizContext = (BizContext)Session["GBAdminBizContext"];
                        }
                        BizContext.SystemCultureCode = "en-Gb";
                        BizContext.CultureCode = "en";
                        Session["GBAdminBizContext"] = BizContext;
                        Session["CultureCode"] = "en";
                    }
                }
                catch
                {
                    string url = "http://freegeoip.net/json/" + UserIP.ToString();
                    WebClient client = new WebClient();
                    string jsonstring = client.DownloadString(url);
                    dynamic dynObj = JsonConvert.DeserializeObject(jsonstring);
                    // System.Web.HttpContext.Current.Session["LocId"] = dynObj.country_code;

                    string countryCode = dynObj.country_code;
                    Session["CountryCodeFromIP"] = countryCode;

                    DataTable Cultures = new DataTable();
                    baseRepo.SQLCon.Open();
                    SqlCommand cmd = new SqlCommand("B_GetCultureAvailableCount_BizTbl_Culture_SP", baseRepo.SQLCon);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Culture", countryCode);
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(Cultures);
                    baseRepo.SQLCon.Close();

                    if (Cultures != null)
                    {
                        if (Cultures.Rows.Count > 0)
                        {
                            foreach (DataRow dr in Cultures.Rows)
                            {

                                if (Session["GBAdminBizContext"] != null)
                                {
                                    BizContext = (BizContext)Session["GBAdminBizContext"];
                                }
                                BizContext.SystemCultureCode = dr["SystemCode"].ToString();
                                BizContext.CultureCode = dr["CultureCode"].ToString();
                                Session["CultureCode"] = dr["CultureCode"].ToString();
                                Session["GBAdminBizContext"] = BizContext;
                            }
                        }
                        else
                        {

                            if (Session["GBAdminBizContext"] != null)
                            {
                                BizContext = (BizContext)Session["GBAdminBizContext"];
                            }
                            BizContext.SystemCultureCode = "en-Gb";
                            BizContext.CultureCode = "en";
                            Session["GBAdminBizContext"] = BizContext;
                            Session["CultureCode"] = "en";
                        }
                    }

                    else
                    {

                        if (Session["GBAdminBizContext"] != null)
                        {
                            BizContext = (BizContext)Session["GBAdminBizContext"];
                        }
                        BizContext.SystemCultureCode = "en-Gb";
                        BizContext.CultureCode = "en";
                        Session["GBAdminBizContext"] = BizContext;
                        Session["CultureCode"] = "en";
                    }
                }
            }
        }
        public JsonResult MonthlyPropertyStatistics(string Year)
        {
            //  string HotelID = Convert.ToString(Session["GBAdminBizContext"]);
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int HotelID = BizContext.HotelID;
            Session["GBAdminBizContext"] = BizContext;

            var PartID = "1";
            if (Year == "")
            {
                Year = "2015";
            }
            DataTable dt = new DataTable();
            PropertyStatisticsRepository objupdate = new PropertyStatisticsRepository();
            List<PropertyStatisticsExt> list = new List<PropertyStatisticsExt>();
            try
            {
                dt = objupdate.MonthlyPropertyStatistics(PartID, HotelID, Year);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        PropertyStatisticsExt FirmObj = new PropertyStatisticsExt();
                        FirmObj.PartID = dr["PartID"].ToString();
                        FirmObj.RecordID = dr["RecordID"].ToString();
                        FirmObj.ReservationCount = dr["ReservationCount"].ToString();
                        FirmObj.HitCount = dr["HitCount"].ToString();
                        FirmObj.MonthName = dr["MonthName"].ToString();
                        list.Add(FirmObj);
                    }
                }
            }
            catch (Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }
            return Json(list, JsonRequestBehavior.AllowGet);
        }
 public ActionResult _Read([DataSourceRequest]DataSourceRequest request)
 {
     PromotionsRepository modelRepo = new PromotionsRepository();
     BizContext = (BizContext)Session["GBAdminBizContext"];
     int id = BizContext.HotelID;
     Session["GBAdminBizContext"] = BizContext;
     DataSourceResult result = modelRepo.ReadAll(id).ToDataSourceResult(request);
     return Json(result);
 }
        public JsonResult SaveRoomAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay,
            string DateIDArray,string WeekDayIDArray,string SinglePriceNameArray,string DoublePriceNameArray,string RoomPriceNameArray,
            string AvailableRoomCountNameArray, string MinimumStayNameArray, string CloseToArrivalArray, string CloseToDepartureArray, string ClosedArray)
        {
            int i = 1;
            int RoomID = Convert.ToInt32(RoomType);
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int Hotelid = BizContext.HotelID;
            long UserSessionID= Convert.ToInt64(BizContext.UserSessionID);
            Session["GBAdminBizContext"] = BizContext;
            RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository();
            try {
            var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID);
            int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms);
            ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms);
            ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy);
            ObjRep.SaveRoomAvailabilityAndRate(Convert.ToInt32(AccommodationType), Convert.ToInt32(PricePolicy), Convert.ToInt32(RoomType), MaximamPeopleCount,
                DateIDArray, SinglePriceNameArray, DoublePriceNameArray, RoomPriceNameArray, AvailableRoomCountNameArray, MinimumStayNameArray,
                CloseToArrivalArray, CloseToDepartureArray, ClosedArray,UserSessionID, this);

            }
            catch (Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }
            return Json(i, JsonRequestBehavior.AllowGet);
        }
        public JsonResult YearlyPropertyStatistics()
        {
            // string HotelID = Convert.ToString(Session["GBAdminBizContext"]);
            BizContext = (BizContext)Session["GBAdminBizContext"];
            int HotelID = BizContext.HotelID;
            Session["GBAdminBizContext"] = BizContext;

            var PartID = "1";

            PropertyStatisticsRepository objupdate = new PropertyStatisticsRepository();
            var yearlyPropertyStatistics = objupdate.YearlyPropertyStatistics(PartID, HotelID);
            ViewBag.yearlyPropertyStatistics = yearlyPropertyStatistics;
            return Json(yearlyPropertyStatistics, JsonRequestBehavior.AllowGet);
        }