Subscription & Schedule handling on Reporting Services API (Part 4)

Finally , let's see how it works!

#region SetUIFromSubscription
  private void SetUIFromSubscription(string _SubscriptionID)
  {
   #region GetSubscriptionProperties
   ExtensionSettings extSettings;
   string desc;
   ActiveState active;
   string status;
   string eventType;
   string matchData;
   ParameterValue[] values = null;
   rs.rs.GetSubscriptionProperties(_SubscriptionID, out extSettings, out desc, out active, out status, out eventType, out matchData, out values);
   #endregion

   #region Schedule
   if(desc!=null && desc.IndexOf('^')>-1 && desc.IndexOf('|')>-1)//Set Remark & Public
   {
    string _logName=desc.Substring(0,desc.IndexOf('^'));
    if(_logName.Equals(Framework.Utility.DefaultAttribute.PUBLIC))
     this.chk_IsPublic.Checked=true;
    if(desc.LastIndexOf(';')>-1)
     this.txt_Remark.Text=desc.Substring(desc.IndexOf('|')+1,desc.LastIndexOf(';')-desc.IndexOf('|')-1);
   }
   //Patch
   if(matchData.IndexOf("WhichWeek")>-1)
   {
    if(matchData.IndexOf("FIRST_WEEK")>-1)
     matchData=matchData.Replace("FIRST_WEEK","FirstWeek");
    if(matchData.IndexOf("SECOND_WEEK")>-1)
     matchData=matchData.Replace("SECOND_WEEK","SecondWeek");
    if(matchData.IndexOf("THIRD_WEEK")>-1)
     matchData=matchData.Replace("THIRD_WEEK","ThirdWeek");
    if(matchData.IndexOf("FOURTH_WEEK")>-1)
     matchData=matchData.Replace("FOURTH_WEEK","FourthWeek");
    if(matchData.IndexOf("LAST_WEEK")>-1)
     matchData=matchData.Replace("LAST_WEEK","LastWeek");
   }

   SetPatten(GetScheduleFromXml(matchData));//Set Patten
   #endregion

   if(extSettings.Extension.Equals("Report Server FileShare"))
    SetUIExtensionSettings(extSettings);
  }
  #endregion

private void Page_Load(object sender, System.EventArgs e)
  {
   rs=ReportServicesSingleton.GetInstance(this);//Post Back & Not Post Back
   if(!Page.IsPostBack && Page.Request.Params["ReportName"]!=null && Page.Request.Params["ReportNo"]!=null)
   {
    try
    {
     this.txtReportName.Text=Page.Request.Params["ReportName"];
     this.txtReportNo.Text=Page.Request.Params["ReportNo"];
     this.txt_StartDate.Text=System.DateTime.Now.ToString("yyyy-MM-dd HH:mm");
     this.txt_FileName.Text=this.txtReportName.Text.Substring(this.txtReportName.Text.LastIndexOf('/')+1);
     this.txt_Path.Text=Framework.Utility.ConstantReader.GetReportConfig("SubscriptionSavingPath");
     this.txt_UserNm.Text=Framework.Utility.ConstantReader.GetReportConfig("User");

     AddOverWriteModel();
     AddRenderFormats();
     AddParameterControl();

     if(Page.Request.Params["SubscriptionID"]!=null)
      SetUIFromSubscription(Page.Request.Params["SubscriptionID"]);
     else
      this.rad_ScheduleHour.Checked=true;
    }
    catch(Exception ex)
    {
     Framework.Utility.JSUtil.Alert(this,ex.Message,ex);
    }
   }
  }

#region btnSave_ServerClick
  private void btnSave_ServerClick(object sender, System.EventArgs e)
  {
   try
   {
    if(this.txt_UserNm.Text.Equals(Framework.Utility.ConstantReader.GetReportConfig("User")))//TO DO ? Same Name on different machines!
     this.txt_Password.Text=Framework.Utility.ConstantReader.GetReportConfig("Password");

    string _oriDesc=string.Format("{2} "+GetMessage("Liter_SubscribeDesc"),this.txt_Path.Text,this.txt_FileName.Text,this.txt_Remark.Text.Length>0?this.txt_Remark.Text+';':string.Empty);
    string _desc=string.Format("{0}^{1}|{2}",this.chk_IsPublic.Checked?Framework.Utility.DefaultAttribute.PUBLIC:this.CurrentUser.LogName,this.txtReportNo.Text,_oriDesc);//保存用户及报表subfix
   
    if(Page.Request.Params["SubscriptionID"]==null)
     rs.rs.CreateSubscription(this.txtReportName.Text,BuildExtensionSettings("Report Server FileShare",FileShareSettings),_desc,
      "TimedSubscription",GetMatchData(),GetReportParamsFromUI());
    else
     rs.rs.SetSubscriptionProperties(Page.Request.Params["SubscriptionID"],BuildExtensionSettings("Report Server FileShare",FileShareSettings),_desc,
      "TimedSubscription",GetMatchData(),GetReportParamsFromUI());
    Framework.Utility.JSUtil.Alert(this,GetMessage("MSG_SUBSCRIBE_SUCESSED"));
    Framework.Utility.JSUtil.CloseWindow(this);
   }
   catch(Exception ex)
   {
    this.btnSave.Disabled=true;
    Framework.Utility.JSUtil.Alert(this,GetMessage("MSG_SUBSCRIBE_FAILED"),ex);
   }
  }
  #endregion

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值