/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="value"></param> protected void FetchSubscribers(DataGridItem item) { DropDownList cboSubscribers = (DropDownList)item.FindControl("cboSubscribers"); if (cboSubscribers != null) { // Caricamento dei sottoscrittori configurati e raggiungibili tramite l'url indicato using (Subscriber.Proxy.SubscriberWebService ws = new Subscriber.Proxy.SubscriberWebService()) { ws.Url = Properties.Settings.Default.SubscriberWebServices; cboSubscribers.DataValueField = "Name"; cboSubscribers.DataTextField = "Name"; cboSubscribers.DataSource = ws.GetChannelList(); cboSubscribers.DataBind(); HiddenField hdSubscriber = (HiddenField)item.FindControl("hdSubscriber"); if (hdSubscriber != null && !string.IsNullOrEmpty(hdSubscriber.Value)) { cboSubscribers.SelectedValue = hdSubscriber.Value; } } } }
/// <summary> /// /// </summary> protected void FetchInstances() { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { this.grdInstances.SelectedIndex = -1; this.grdInstances.DataSource = da.GetChannelList(); this.grdInstances.DataBind(); this.ClearRules(); } }
/// <summary> /// Notifica evento al SubScriber /// </summary> /// <param name="channelRef"></param> /// <param name="logInfo"></param> /// <param name="obj"></param> /// <returns></returns> protected virtual Subscriber.Proxy.ListenerResponse NotifyEvent(ChannelRefInfo channelRef, VtDocs.LogInfo logInfo, Subscriber.Proxy.PublishedObject obj) { logger.Debug("Start. " + channelRef.ChannelName); Subscriber.Proxy.EventInfo eventInfo = new Subscriber.Proxy.EventInfo { EventName = logInfo.EventCode, EventDate = DateTime.Now, Author = new Subscriber.Proxy.EventAuthorInfo { Name = logInfo.UserName, RoleName = logInfo.RoleDescription }, PublishedObject = obj }; logger.DebugFormat("Eventname: {0}, Eventdate: {1}, Author user: {2}, Role {3}", eventInfo.EventName, eventInfo.EventDate.ToString(), eventInfo.Author.Name, eventInfo.Author.RoleName); Subscriber.Proxy.ListenerResponse response = null; Subscriber.Proxy.ChannelInfo channelInfo = null; using (Subscriber.Proxy.SubscriberWebService subscriber = new Subscriber.Proxy.SubscriberWebService()) { subscriber.Url = channelRef.SubscriberServiceUrl; logger.DebugFormat("Sub Url: {0}. Prelievo canali", subscriber.Url); Subscriber.Proxy.ChannelInfo[] channels = subscriber.GetChannelList(); if (channels != null) { logger.Debug("Channel trovati. N " + channels.Length + ""); for (int i = 0; i < channels.Length; i++) { logger.Debug(channels[i].Name); } channelInfo = channels.Where(e => e.Name == channelRef.ChannelName).First(); if (channelInfo == null) { // Istanza di pubblicazione non trovata nel subscriber collegato logger.Debug("Istanza di pubblicazione non trovata nel subscriber collegato"); throw new PublisherException(ErrorCodes.PUBLISH_CHANNEL_NOT_FOUND, ErrorDescriptions.PUBLISH_CHANNEL_NOT_FOUND); } } logger.Debug("Chiamo il notify Event"); response = subscriber.NotifyEvent( new Subscriber.Proxy.ListenerRequest { ChannelInfo = channelInfo, EventInfo = eventInfo } ); } return(response); }
/// <summary> /// /// </summary> /// <param name="idRule"></param> protected void FetchSubRuleOptions(int idRule) { this.hdParentRuleId.Value = idRule.ToString(); this.hdIsSubRule.Value = "true"; using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.SubRuleInfo rule = da.GetSubRule(idRule); this.grdRuleOptions.DataSource = rule.Options; this.grdRuleOptions.DataBind(); } }
/// <summary> /// /// </summary> /// <param name="idInstance"></param> protected void FetchRules(int idInstance) { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { this.grdRules.SelectedIndex = -1; this.grdRules.DataSource = da.GetRules(idInstance); this.grdRules.DataBind(); this.ClearRuleOptions(); this.ClearSubRules(); } }
/// <summary> /// /// </summary> /// <param name="idRule"></param> protected void FetchSubRules(int idRule) { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.RuleInfo rule = da.GetRule(idRule); this.grdSubRules.SelectedIndex = -1; this.grdSubRules.DataSource = rule.SubRules; this.grdSubRules.DataBind(); this.ClearRuleOptions(); this.ClearRuleHistory(); } }
/// <summary> /// /// </summary> /// <param name="id"></param> protected void FetchRuleHistoryItem(int id) { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.RuleHistoryInfo historyInfo = da.GetHistoryItem(id); if (historyInfo != null) { this.grdPublishedObject.SelectedIndex = -1; this.grdPublishedObject.DataSource = historyInfo.ObjectSnapshot.Properties.Where(e => !e.Hidden); this.grdPublishedObject.DataBind(); if (historyInfo.MailMessageSnapshot != null) { this.txtAppointmentAsText.Text = historyInfo.MailMessageSnapshot.AppointmentAsText; } } } }
/// <summary> /// Reperimento dei sottoscrittori disponibili nel sistema /// </summary> /// <returns></returns> private Subscriber.Proxy.ChannelInfo[] GetSubscribers(string serviceUrl) { //if (!this.PingSubscriberServices(serviceUrl)) // throw new ApplicationException("Servizio sottoscrittore non raggiungibile"); try { // Caricamento dei sottoscrittori configurati e raggiungibili tramite l'url indicato using (Subscriber.Proxy.SubscriberWebService ws = SubscriberServiceFactory.Create(serviceUrl)) return(ws.GetChannelList()); } catch (System.Web.Services.Protocols.SoapException soapEx) { ApplicationException ex = DocsPaUtils.Exceptions.SoapExceptionParser.GetOriginalException(soapEx); throw ex; } catch (Exception ex) { throw new ApplicationException("Servizio sottoscrittore non raggiungibile"); } }
/// <summary> /// /// </summary> /// <param name="idRule"></param> protected void FetchRuleHistory(int idRule) { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.GetRuleHistoryListRequest request = new Subscriber.Proxy.GetRuleHistoryListRequest { IdRule = idRule, PagingContext = new Subscriber.Proxy.PagingContextInfo { PageNumber = 1, ObjectsPerPage = Int32.MaxValue }, CustomFilters = null }; Subscriber.Proxy.GetRuleHistoryListResponse response = da.GetRuleHistoryList(request); this.grdRulesHistory.SelectedIndex = -1; this.grdRulesHistory.DataSource = response.Rules; this.grdRulesHistory.DataBind(); this.ClearRuleHistoryDetail(); } }
/// <summary> /// Creazione servizio per il sottoscrittore /// </summary> /// <param name="serviceUrl"> /// Url del servizio sottoscrittore /// </param> /// <returns></returns> public static Subscriber.Proxy.SubscriberWebService Create(string serviceUrl) { Subscriber.Proxy.SubscriberWebService instance = new Subscriber.Proxy.SubscriberWebService(); instance.Url = serviceUrl; return(instance); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdRuleOptions_ItemCommand(object sender, DataGridCommandEventArgs e) { int idRule; Int32.TryParse(this.hdParentRuleId.Value, out idRule); bool isSubRule; bool.TryParse(this.hdIsSubRule.Value, out isSubRule); if (e.CommandName == "Select") { //this.grdRuleOptions.EditItemIndex = e.Item.ItemIndex; //this.FetchRuleOptions(idRule); } else if (e.CommandName == "Update") { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { if (isSubRule) { Subscriber.Proxy.SubRuleInfo rule = da.GetSubRule(idRule); string name = ((TextBox)e.Item.FindControl("txtName")).Text; string value = ((TextBox)e.Item.FindControl("txtValue")).Text; List <Subscriber.Proxy.NameValuePair> pairs = new List <Subscriber.Proxy.NameValuePair>(rule.Options); Subscriber.Proxy.NameValuePair pair = pairs.Where(itm => itm.Name.ToLowerInvariant() == name.ToLowerInvariant()).FirstOrDefault(); if (pair == null) { pair = new Subscriber.Proxy.NameValuePair(); pairs.Add(pair); } pair.Name = name; pair.Value = value; rule.Options = pairs.ToArray(); rule = da.SaveSubRule(rule); this.grdRuleOptions.EditItemIndex = -1; this.FetchSubRuleOptions(idRule); } else { Subscriber.Proxy.RuleInfo rule = da.GetRule(idRule); string name = ((TextBox)e.Item.FindControl("txtName")).Text; string value = ((TextBox)e.Item.FindControl("txtValue")).Text; List <Subscriber.Proxy.NameValuePair> pairs = new List <Subscriber.Proxy.NameValuePair>(rule.Options); Subscriber.Proxy.NameValuePair pair = pairs.Where(itm => itm.Name.ToLowerInvariant() == name.ToLowerInvariant()).FirstOrDefault(); if (pair == null) { pair = new Subscriber.Proxy.NameValuePair(); pairs.Add(pair); } pair.Name = name; pair.Value = value; rule.Options = pairs.ToArray(); rule = da.SaveRule(rule); this.grdRuleOptions.EditItemIndex = -1; this.FetchRuleOptions(idRule); } } } else if (e.CommandName == "Cancel") { this.grdRuleOptions.EditItemIndex = -1; this.FetchRuleOptions(idRule); } else if (e.CommandName == "Delete") { using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { if (isSubRule) { Subscriber.Proxy.SubRuleInfo rule = da.GetSubRule(idRule); List <Subscriber.Proxy.NameValuePair> pairs = new List <Subscriber.Proxy.NameValuePair>(rule.Options); pairs.RemoveAt(e.Item.ItemIndex); rule.Options = pairs.ToArray(); rule = da.SaveSubRule(rule); this.grdRuleOptions.EditItemIndex = -1; this.FetchSubRuleOptions(idRule); } else { Subscriber.Proxy.RuleInfo rule = da.GetRule(idRule); List <Subscriber.Proxy.NameValuePair> pairs = new List <Subscriber.Proxy.NameValuePair>(rule.Options); pairs.RemoveAt(e.Item.ItemIndex); rule.Options = pairs.ToArray(); rule = da.SaveRule(rule); this.grdRuleOptions.EditItemIndex = -1; this.FetchRuleOptions(idRule); } } } }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void grdSubRules_ItemCommand(object source, DataGridCommandEventArgs e) { Label lblId = (Label)e.Item.FindControl("lblId"); int id; Int32.TryParse(lblId.Text, out id); if (e.CommandName == "Select") { Label lblIdParentRule = (Label)e.Item.FindControl("lblIdParentRule"); this.grdSubRules.EditItemIndex = e.Item.ItemIndex; this.FetchSubRules(Convert.ToInt32(lblIdParentRule.Text)); this.FetchSubRuleOptions(id); this.FetchRuleHistory(id); } else if (e.CommandName == "Update") { Label lblIdParentRule = (Label)this.grdRules.SelectedItem.FindControl("lblId"); int idParentRule = Convert.ToInt32(lblIdParentRule.Text); Label lblIdInstance = (Label)this.grdInstances.SelectedItem.FindControl("lblId"); int idInstance = Convert.ToInt32(lblIdInstance.Text); using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.SubRuleInfo rule = null; if (id > 0) { rule = da.GetSubRule(id); } else { rule = new Subscriber.Proxy.SubRuleInfo(); rule.Id = id; rule.IdInstance = idInstance; rule.IdParentRule = idParentRule; rule.SubRuleName = ((TextBox)e.Item.FindControl("txtSubRuleName")).Text; } rule.RuleDescription = ((TextBox)e.Item.FindControl("txtRuleDescription")).Text; rule.Enabled = ((CheckBox)e.Item.FindControl("chkRuleEnabled")).Checked; rule = da.SaveSubRule(rule); } this.grdSubRules.EditItemIndex = -1; this.FetchSubRules(idParentRule); } else if (e.CommandName == "Cancel") { Label lblIdParentRule = (Label)this.grdRules.SelectedItem.FindControl("lblId"); int idParentRule = Convert.ToInt32(lblIdParentRule.Text); this.grdSubRules.EditItemIndex = -1; this.FetchSubRules(idParentRule); } else if (e.CommandName == "Delete") { Label lblIdParentRule = (Label)e.Item.FindControl("lblIdParentRule"); int idParentRule = Convert.ToInt32(lblIdParentRule.Text); using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { da.DeleteRule(id); } this.grdSubRules.EditItemIndex = -1; this.FetchSubRules(idParentRule); } }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void grdInstances_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Select") { this.grdInstances.EditItemIndex = e.Item.ItemIndex; this.FetchInstances(); Label lblId = (Label)e.Item.FindControl("lblId"); if (!string.IsNullOrEmpty(lblId.Text)) { this.FetchRules(Convert.ToInt32(lblId.Text)); } } else if (e.CommandName == "Edit") { } else if (e.CommandName == "Update") { Label lblId = (Label)e.Item.FindControl("lblId"); int id = Convert.ToInt32(lblId.Text); using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { Subscriber.Proxy.ChannelInfo instance = new Subscriber.Proxy.ChannelInfo(); instance.Id = id; instance.Name = ((TextBox)e.Item.FindControl("txtName")).Text; instance.Description = ((TextBox)e.Item.FindControl("txtDescription")).Text; instance.SmtpHost = ((TextBox)e.Item.FindControl("txtSmtpHost")).Text; instance.SmtpPort = Convert.ToInt32(((TextBox)e.Item.FindControl("txtSmtpPort")).Text); instance.SmtpSsl = ((CheckBox)e.Item.FindControl("txtSmtpSsl")).Checked; instance.SmtpUserName = ((TextBox)e.Item.FindControl("txtSmtpUserName")).Text; instance.SmtpPassword = ((TextBox)e.Item.FindControl("txtSmtpPassword")).Text; instance.SmtpMail = ((TextBox)e.Item.FindControl("txtSmtpMail")).Text; instance = da.SaveChannel(instance); } this.grdInstances.EditItemIndex = -1; this.FetchInstances(); } else if (e.CommandName == "Delete") { Label lblId = (Label)e.Item.FindControl("lblId"); int id = Convert.ToInt32(lblId.Text); using (Subscriber.Proxy.SubscriberWebService da = this.CreateService()) { da.DeleteChannel(id); } this.FetchInstances(); } else if (e.CommandName == "Cancel") { this.grdInstances.EditItemIndex = -1; this.FetchInstances(); } }