public DC_Message AddUpdateSchedule(MDMSVC.DC_Supplier_Schedule RQParams) { object result = null; ServiceConnection.MDMSvcProxy.PostData(ConfigurationManager.AppSettings["Supplier_AddUpdateSchedule"], RQParams, typeof(MDMSVC.DC_Supplier_Schedule), typeof(DC_Message), out result); return(result as DC_Message); }
public void SupplierSchedulesave() { try { string frequencyvalue = Request.Form["ddl_period"]; string expression = cron_expression.Value; List <MDMSVC.DC_Supplier_Schedule> _objresult = new List <MDMSVC.DC_Supplier_Schedule>(); _objresult = GetListOfScheduleBySupplier(); Guid SupplierScheduleID = Guid.Empty; Guid mySupplier_Id = Guid.Parse(Request.QueryString["Supplier_Id"]); MDMSVC.DC_Supplier_Schedule _objSupSch = new MDMSVC.DC_Supplier_Schedule(); if (_objresult != null && _objresult.Count > 0) { if (Session["SupplierScheduleId"] != null) { SupplierScheduleID = (Guid)(Session["SupplierScheduleId"]); } //mySupplier_Id = _objresult[0].Suppllier_ID; _objSupSch.SupplierScheduleID = SupplierScheduleID; _objSupSch.Create_User = _objSupSch.Create_User; _objSupSch.Create_Date = _objSupSch.Create_Date; _objSupSch.Edit_Date = DateTime.Now; _objSupSch.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; } if (SupplierScheduleID == Guid.Empty) { _objSupSch.Create_Date = DateTime.Now; _objSupSch.Create_User = System.Web.HttpContext.Current.User.Identity.Name; } _objSupSch.Suppllier_ID = mySupplier_Id; _objSupSch.ISXMLSupplier = Convert.ToBoolean(Convert.ToInt16(rdbtnIsAPIXMLSupplier.SelectedValue)); _objSupSch.ISUpdateFrequence = Convert.ToBoolean(Convert.ToInt16(rdbIsUpdateFrequencyRequired.SelectedValue)); StringBuilder sbFrequencyTypeCode = new StringBuilder(); sbFrequencyTypeCode.Append(frequencyvalue); //if (Convert.ToBoolean(Convert.ToInt16(rdbtnIsAPIXMLSupplier.SelectedValue))) //{ #region Yearly if (frequencyvalue == "Y") { //_objSupSch.Recur_No = Convert.ToInt32(txtRecurEvery_Year.Text); string Yearly_type = Request.Form["yearlyType"]; if (Yearly_type == "byDay") { sbFrequencyTypeCode.Append("M"); _objSupSch.MonthOfYear = Convert.ToInt32(Request.Form["ddl_yearly_Month"]); _objSupSch.DateOfMonth = Convert.ToInt32(Request.Form["ddl_yearly_day"]); } else if (Yearly_type == "byWeek") { sbFrequencyTypeCode.Append("W"); _objSupSch.WeekOfMonth = Convert.ToInt32(Request.Form["ddl_yearly_nthday"]); string strDays = Convert.ToString("0000000").Remove(Convert.ToInt32(Request.Form["ddl_yearly_day_od_week"]) - 1, 1).Insert(Convert.ToInt32(Request.Form["ddl_yearly_day_od_week"]) - 1, "1"); // string strDays = "00000000"; _objSupSch.DayOfWeek = strDays; _objSupSch.MonthOfYear = Convert.ToInt32(Request.Form["ddl_yearly_month_by_week"]); } } #endregion #region Monthly if (frequencyvalue == "M") { string Monthly_type = Request.Form["monthlyType"]; if (Monthly_type == "byDay") { sbFrequencyTypeCode.Append("D"); _objSupSch.DateOfMonth = Convert.ToInt32(Request.Form["ddl_monthly_day"]); _objSupSch.Recur_No = Convert.ToInt32(Request.Form["ddl_monthly_monthly"]); } else if (Monthly_type == "byWeek") { sbFrequencyTypeCode.Append("W"); _objSupSch.WeekOfMonth = Convert.ToInt32(Request.Form["ddl_monthly_nthday"]); string strDays = Convert.ToString("0000000").Remove(Convert.ToInt32(Request.Form["ddl_monthly_day_of_week"]) - 1, 1).Insert(Convert.ToInt32(Request.Form["ddl_monthly_day_of_week"]) - 1, "1"); _objSupSch.DayOfWeek = strDays; //_objSupSch.DayOfWeek = ("1" + strDays.Substring(0, (Convert.ToInt32(ddlTheDaysOf_Month.SelectedValue) - 1))).PadLeft(7, '0'); _objSupSch.Recur_No = Convert.ToInt32(Request.Form["ddl_monthly_month_by_week"]); } } #endregion #region Weekly if (frequencyvalue == "W") { //_objSupSch.Recur_No = Convert.ToInt32(txtRecur_Weekly.Text); string test = Request.Form["dayOfWeek"]; int[] nums = test.Split(',').Select(int.Parse).ToArray(); //1001011 2571 1100101 StringBuilder sbDay = new StringBuilder("0000000"); foreach (int i in nums) { if (i != 1) { sbDay[Convert.ToInt32(i) - 2] = '1'; // selected.Add(item); } else { sbDay[Convert.ToInt32(6)] = '1'; } } _objSupSch.DayOfWeek = sbDay.ToString(); } #endregion #region Daily if (frequencyvalue == "D") { _objSupSch.Recur_No = Convert.ToInt32(Request.Form["ddl_daily"]); } #endregion #region Hourly if (frequencyvalue == "H") { _objSupSch.Recur_No = Convert.ToInt32(Request.Form["ddl_hourly"]); } #endregion _objSupSch.FrequencyTypeCode = sbFrequencyTypeCode.ToString(); _objSupSch.Status = Convert.ToString(ddlStatus.SelectedValue); //Need To Do string startHour = Request.Form["ddl_clock_hour"]; string startminute = Request.Form["ddl_clock_minute"]; if (Convert.ToInt32(startHour) < 9) { startHour = startHour.ToString().PadLeft(2, '0'); //startHour = '0' + startHour; } if (Convert.ToInt32(startminute) < 9) { startminute = startminute.ToString().PadLeft(2, '0'); //startminute = '0' + startminute; } _objSupSch.StartTime = Convert.ToString(startHour + ":" + startminute); //_objSupSch.StartTime = Convert.ToString(timepickerStart_Hourly.Value); //_objSupSch.EndTime = Convert.ToString(timepickerEnd_Hourly.Value); //} List <string> selected = new List <string>(); foreach (ListItem item in Checkentitysequence.Items) { if (item.Selected) { selected.Add(item.Text); _objSupSch.lstEnity = selected.ToArray(); } } _objSupSch.CronExpression = expression; _objSupSch.User_Role_Id = Convert.ToString(ddlUserRoleId.SelectedValue); //MDMSVC.DC_Supplier_Schedule_RQ obj = new DC_Supplier_Schedule_RQ(); //obj.Suppllier_ID = _objSupSch.Suppllier_ID; //obj.Entities = _objSupSch.lstEnity; //var result = _objSchedularService.CheckSupplierScheduleData(obj); //if (result == false) //{ // //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), DateTime.Now.Ticks.ToString(), "alert('record alreday exist');e.preventDefault();e.stopPropagation(); return false;", true); // BootstrapAlert.BootstrapAlertMessage(msgAlert, "One of Entity Record Already Exist", BootstrapAlertType.Information); //} //else //{ MDMSVC.DC_Message _objMsg = _objSchedularService.AddUpdateSchedule(_objSupSch); if (_objMsg != null) { BootstrapAlert.BootstrapAlertMessage(msgAlert, "" + _objMsg.StatusMessage, (BootstrapAlertType)_objMsg.StatusCode); } LoadSupplierScheduleData(); //} } catch (Exception ex) { throw ex; } }