/// <summary> /// Set action which doesn't require an ID. /// </summary> /// <param name="action"></param> /// <returns></returns> protected void SetRequestAction(Enum action) { RequestAction requestAction = action.ParseEnumValue <RequestAction>(); switch (requestAction) { case RequestAction.Send: Path += "/send"; break; case RequestAction.Import: Path += "/import"; break; case RequestAction.Create: case RequestAction.List: case RequestAction.Insert: break; case RequestAction.Patch: case RequestAction.Update: case RequestAction.Delete: case RequestAction.Get: case RequestAction.Modify: case RequestAction.Trash: case RequestAction.Untrash: throw new ArgumentException($"Action \'{action}\' requires an ID", nameof(action)); default: throw new ArgumentOutOfRangeException(nameof(action)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BitAuto.YanFa.SysRightManager.Common.UserInfo.Check(); string msg = string.Empty; switch (RequestAction.ToLower()) { case "bindknowledgecategory": BindKnowledgeCategory(out msg); break; case "bindchildrencategoryinfo": BindChildrenCategoryInfo(out msg); break; case "knowledgecategoryupdate": KnowledgeCategoryUpdate(out msg); break; case "knowledgecategoryinsert": KnowledgeCategoryInsert(out msg); break; case "knowledgecategorydelete": KnowledgeCategoryDelete(out msg); break; case "knowledgecategorystatuschange": KnowledgeCategoryStatusChange(out msg); break; case "deleteknowledgecategoryandchildren": DeleteKnowledgeCategoryAndChildren(out msg); break; case "sortnumupordown": SortNumUpOrDown(out msg); break; } context.Response.Write(msg); }
/// <summary> /// Searches for a subscription with the proper subscriber, request action, and group /// </summary> /// <typeparam name="S">Signal Type</typeparam> /// <typeparam name="R">Response Type</typeparam> /// <param name="group">Group</param> /// <returns>subscription if found</returns> private ISubscription _GetSubscription <S, R>(ISubscriber subscriber, RequestAction <S, R> action, long?group = null) { var signalKey = new SignalKey(typeof(S), typeof(R), group); IList subscriptionList; // If the signal type is not found, then create a new signal type in the dictionary if (_subscriptions.TryGetValue(signalKey, out subscriptionList)) { // cast the subscription list to the appropriate type LiteList <RequestSubscription <S, R> > typeList = (LiteList <RequestSubscription <S, R> >)subscriptionList; // search through the subscriptions for one that has the correct // subscriber and action for (var i = 0; i < typeList.Count; i++) { if (typeList[i]._Subscriber == subscriber && typeList[i].Action == action ) { return(typeList[i]); } } } return(null); }
public ObsRequestNode(XPathNavigator nav) { ID = nav.SelectSingleNode ("@id").Value; Description = nav.SelectSingleNode ("description").Value; State = new RequestState (nav.SelectSingleNode ("state")); Action = new RequestAction (nav.SelectSingleNode ("action")); }
/// <summary> /// Initializes a new instance of the <see cref="GatewayRequest"/> class. /// </summary> public GatewayRequest() { Post = new NameValueCollection(); _post = new StringBuilder(); LoadCoreValues(); _apiAction = RequestAction.AuthorizeAndCapture; }
public async Task <IActionResult> PutRequestAction([FromRoute] string id, [FromBody] RequestAction requestAction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != requestAction.RequestId) { return(BadRequest()); } _context.Entry(requestAction).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestActionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
internal void SetApiAction(RequestAction action) { _apiAction = action; var apiValue = "AUTH_CAPTURE"; switch (action) { case RequestAction.Authorize: apiValue = "AUTH_ONLY"; break; case RequestAction.Capture: apiValue = "CAPTURE_ONLY"; break; case RequestAction.UnlinkedCredit: case RequestAction.Credit: apiValue = "CREDIT"; break; case RequestAction.Void: apiValue = "VOID"; break; case RequestAction.PriorAuthCapture: apiValue = "PRIOR_AUTH_CAPTURE"; break; } Queue(ApiFields.TransactionType, apiValue); }
public WebUI() { NINSS.MinecraftConnector.ServerStop += OnStop; NINSS.MinecraftConnector.PlayerChatReceived += ChatReceived; OnRequest += LogAction; OnRequest += PluginsAction; OnRequest += CommandAction; OnRequest += ConfigAction; OnRequest += ConfigsAction; OnRequest += ConfigListAction; try { NINSS.API.Config config = new NINSS.API.Config("WebUI"); string _ip = config.GetValue("IP_Adress"); this.ip = System.Net.IPAddress.Parse(_ip); port = Convert.ToInt32(config.GetValue("Port")); serverThread = new Thread(new ThreadStart(listen)); serverThread.Start(); } catch (Exception e) { Console.WriteLine("\nError loading WebUI: "+e.GetType().ToString()+": "+e.Message+"\nStacktrace:\n"+e.StackTrace+"\n"); if(e.InnerException != null) Console.WriteLine("InnerException: "+e.InnerException.Message+"\nInner Stacktrace:\n"+e.InnerException.StackTrace); } }
public void ProcessRequest(HttpContext context) { BitAuto.YanFa.SysRightManager.Common.UserInfo.Check(); context.Response.ContentType = "text/plain"; string msg = string.Empty; userID = BLL.Util.GetLoginUserID(); switch (RequestAction.ToLower()) { case "judgeiscorrect": judgeIsCorrect(out msg); break; case "surveyanswersubmit": try { surveyAnswerSubmit(out msg); } catch (Exception ex) { BitAuto.ISDC.CC2012.BLL.Loger.Log4Net.Error("[TakingAnSurveyHandler.ashx]surveyAnswerSubmit...任务ID:" + RequestPTID, ex); } break; } context.Response.Write("{msg:'" + msg + "'}"); }
/// <summary> /// Create a copy of the request with the specified request-configuration actions. /// </summary> /// <param name="request"> /// The HTTP request. /// </param> /// <param name="requestActions"> /// A delegate that configures outgoing request messages. /// </param> /// <returns> /// The new <see cref="HttpRequest"/>. /// </returns> public static HttpRequest WithRequestAction(this HttpRequest request, params RequestAction[] requestActions) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (requestActions == null) { throw new ArgumentNullException(nameof(requestActions)); } if (requestActions.Length == 0) { return(request); } return(request.Clone(properties => { properties[nameof(HttpRequest.RequestActions)] = request.RequestActions.AddRange( requestActions.Select(requestAction => { RequestAction <object> requestActionWithContext = (message, context) => requestAction(message); return requestActionWithContext; }) ); })); }
public WebUI() { NINSS.MinecraftConnector.ServerStop += OnStop; NINSS.MinecraftConnector.PlayerChatReceived += ChatReceived; OnRequest += LogAction; OnRequest += PluginsAction; OnRequest += CommandAction; OnRequest += ConfigAction; OnRequest += ConfigsAction; OnRequest += ConfigListAction; try { NINSS.API.Config config = new NINSS.API.Config("WebUI"); string _ip = config.GetValue("IP_Adress"); this.ip = System.Net.IPAddress.Parse(_ip); port = Convert.ToInt32(config.GetValue("Port")); serverThread = new Thread(new ThreadStart(listen)); serverThread.Start(); } catch (Exception e) { Console.WriteLine("\nError loading WebUI: " + e.GetType().ToString() + ": " + e.Message + "\nStacktrace:\n" + e.StackTrace + "\n"); if (e.InnerException != null) { Console.WriteLine("InnerException: " + e.InnerException.Message + "\nInner Stacktrace:\n" + e.InnerException.StackTrace); } } }
public void ActionDone() { Time.timeScale = 1; Game.onRequestAction = false; actionToDo = RequestAction.none; textMesh.gameObject.SetActive(false); textMesh.text = string.Empty; }
public JsonApiRequest(string userName, RequestAction action, string body, Dictionary <string, StringValues> headers, Dictionary <string, StringValues> query) { Action = action; UserName = userName; Body = body; Headers = headers; Query = query; }
public MessageRequest(RequestAction action = RequestAction.doNothing, string path = null, string identifier = null, string value = null) { Debug.WriteLine($"Constructing request for action {action}"); this.action = action; this.path = path; this.identifier = identifier; this.value = value; }
/// <summary> /// simpler initialization of Headers and Query /// </summary> public static JsonApiRequest Create(string userName, RequestAction action, string body, Dictionary <string, object> headers = null, Dictionary <string, object> query = null) { return(new JsonApiRequest(userName, action, body, ConvertDictionary(headers), ConvertDictionary(query))); Dictionary <string, StringValues> ConvertDictionary(Dictionary <string, object> dictionary) => (dictionary != null) ? dictionary.ToDictionary(item => item.Key, item => new StringValues(new string[] { item.Value.ToString() })) : null; }
private async Task SendBuildRequest(Unit worker, int unitType, Point2D point) { var requestDebug = new RequestDebug(); DebugDraw debugDraw = new DebugDraw(); debugDraw.Boxes.Add(new DebugBox { Min = new Point { X = point.X - 1, Y = point.Y - 1, Z = 14 }, // Z?? Max = new Point { X = point.X + 1, Y = point.Y + 1, Z = 11 }, Color = new Color { R = 180, G = 255, B = 255 } }); requestDebug.Debug.Add(new DebugCommand { Draw = debugDraw }); await _connectionService.SendRequestAsync(new Request { Debug = requestDebug }); // move there first var action2 = new Action(); action2.ActionRaw = new ActionRaw(); action2.ActionRaw.UnitCommand = new ActionRawUnitCommand(); action2.ActionRaw.UnitCommand.AbilityId = 19; // Move abilitiy action2.ActionRaw.UnitCommand.UnitTags.Add(worker.Tag); action2.ActionRaw.UnitCommand.TargetWorldSpacePos = point; var action = new Action(); action.ActionRaw = new ActionRaw(); action.ActionRaw.UnitCommand = new ActionRawUnitCommand(); action.ActionRaw.UnitCommand.AbilityId = _gameDataService.GetAbilityId(unitType); action.ActionRaw.UnitCommand.UnitTags.Add(worker.Tag); action.ActionRaw.UnitCommand.TargetWorldSpacePos = point; // move back to mining var backToMining = new Action(); backToMining.ActionRaw = new ActionRaw(); backToMining.ActionRaw.UnitCommand = new ActionRawUnitCommand(); backToMining.ActionRaw.UnitCommand.QueueCommand = true; backToMining.ActionRaw.UnitCommand.AbilityId = 295; // Gather ability TODO: (scv specific!) backToMining.ActionRaw.UnitCommand.UnitTags.Add(worker.Tag); backToMining.ActionRaw.UnitCommand.TargetUnitTag = Game.MapManager.GetMineralInMainBase(); var requestAction = new RequestAction(); //requestAction.Actions.Add(action2); requestAction.Actions.Add(action); requestAction.Actions.Add(backToMining); await _connectionService.SendRequestAsync(new Request { Action = requestAction }); }
public void ProcessRequest(HttpContext context) { BitAuto.YanFa.SysRightManager.Common.UserInfo.Check(); context.Response.ContentType = "text/plain"; if (RequestAction.ToLower() == "sendemailforrecorderror") { SendEmailForRecordError(); } }
/// <summary> /// Subscribe to a particular request signal type. /// </summary> /// <typeparam name="S">The type of the signal to subscribe to</typeparam> /// <typeparam name="R">The return type of the response</typeparam> /// <param name="subscriber">The receiver that is subscribing to the signal</param> /// <param name="action">The delegate to perform on the receiver when the signal is broadcast</param> /// <param name="group">An optional group to narrow the broadcast to a small group. Default = null</param> /// <param name="order">The optional order that the receiver should be broadcast to. Default = 0</param> /// <returns></returns> public RequestSubscription <S, R> Subscribe <S, R>(ISubscriber subscriber, RequestAction <S, R> action, long?group = null, long order = 0) { var subscription = new RequestSubscription <S, R>(subscriber, action, group, order); _QueueUpdateOrder <S, R>(subscription, order); return(subscription); }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { RequestAction?.Invoke(request); var response = await base.SendAsync(request, cancellationToken); ResponseAction?.Invoke(response); return(response); }
public IEnumerator Run <T>( UnityAction <AsyncResult <T> > callback, [CanBeNull] GameSession gameSession, RequestAction <T> requestAction) { bool isReopenTried = false; bool isAuthenticationTried = false; AsyncResult <T> asyncResult = null; while (true) { yield return(requestAction.Invoke(ar => asyncResult = ar)); if (asyncResult.Error is SessionNotOpenException && !isReopenTried) { isReopenTried = true; AsyncResult <OpenResult> asyncOpenResult = null; yield return(_reopener.ReOpen(Gs2Session, Gs2RestSession, aor => asyncOpenResult = aor)); _reopener.Callback?.Invoke(asyncOpenResult); if (asyncOpenResult.Error == null) { continue; } } var authenticator = _authenticator; if (gameSession != null && authenticator != null && asyncResult.Error is UnauthorizedException && !isAuthenticationTried) { isAuthenticationTried = true; AsyncResult <AccessToken> asyncAuthenticationResult = null; yield return(authenticator.Authentication(aar => asyncAuthenticationResult = aar)); if (asyncAuthenticationResult.Error == null) { gameSession.AccessToken = asyncAuthenticationResult.Result; } authenticator.Callback?.Invoke(asyncAuthenticationResult); if (asyncAuthenticationResult.Error == null) { continue; } } break; } callback.Invoke(asyncResult); }
public DefaultSearchRequestFailed(Guid searchRequestId, string requestId, string searchRequestKey, string cause, RequestAction action) { RequestId = requestId; SearchRequestId = searchRequestId; Action = action; Cause = cause; TimeStamp = DateTime.Now; SearchRequestKey = searchRequestKey; }
public void UpdateRequest(int id, RequestAction requestAction) { var requestMessage = _requestMessageRepository.GetById(id); if (requestMessage != null) { requestMessage.RequestAction = requestAction; _requestMessageRepository.Update(requestMessage); } }
public void Process(RequestAction action) { try { this.rule[this.state][action](); } catch (KeyNotFoundException) { throw new InvalidOperationException(string.Format("Invalid state transistion from {0} with action {1}", this.state, action)); } }
/// <summary> /// UnSubscribe to a particular request signal type. /// </summary> /// <typeparam name="S">The type of the signal to subscribe to</typeparam> /// <typeparam name="R">The return type of the response</typeparam> /// <param name="subscriber">The receiver that is subscribing to the signal</param> /// <param name="action">The delegate to perform on the receiver when the signal is broadcast</param> /// <param name="group">An optional group to narrow the broadcast to a small group. Default = null</param> /// <returns>True if successful</returns> public bool UnSubscribe <S, R>(ISubscriber subscriber, RequestAction <S, R> action, long?group = null) { var subscription = _GetSubscription <S, R>(subscriber, action, group); if (subscription != null) { return(_QueueUnSubscribe(subscription)); } return(false); }
public EventEditorForm(MainDataContexts dataContexts, Event managedEvent, RequestAction requestAction, ENotifySenderManager manager) { InitializeComponent(); _dataContexts = dataContexts; _managedEvent = managedEvent; _requestAction = requestAction; _manager = manager; _indexValues = new BindingList<IndexValues>(); _receiversLists = new List<NotifyReceiversList>(); _contacts = new List<string>(); }
public async Task <IActionResult> FriendResuest(int userId, int friendId, RequestAction choice) { var friendships = await _context.Friendships.ToListAsync(); switch (choice) { case RequestAction.Send: { Friendship f1 = new Friendship() { UserId = userId, FriendId = friendId, Relation = RelationshipStatus.Sending }; Friendship f2 = new Friendship() { UserId = friendId, FriendId = userId, Relation = RelationshipStatus.Pending }; _context.Friendships.Add(f1); _context.Friendships.Add(f2); break; } case RequestAction.Accept: { var f1 = _context.Friendships.First(fs => (fs.UserId == userId && fs.FriendId == friendId)); var f2 = _context.Friendships.First(fs => (fs.UserId == friendId && fs.FriendId == userId)); f1.Relation = RelationshipStatus.Friends; f2.Relation = RelationshipStatus.Friends; break; } case RequestAction.Decline: { var fss = _context.Friendships.Where(fs => ((fs.UserId == userId && fs.FriendId == friendId) || (fs.UserId == friendId && fs.FriendId == userId))); _context.Friendships.RemoveRange(fss); break; } } await _context.SaveChangesAsync(); var users = await _context.Users.ToListAsync(); var frds = await _context.Friendships.ToListAsync(); User user = _context.Users.Include("Friendships").First(u => u.UserId == userId); assignFriends(user, user.Friendships.ToList()); return(Ok(user)); }
public void WithSameValueName_ReturnsRequestedTypeValue() { // Arrange const LabelRequestAction labelAction = LabelRequestAction.Create; // nr. 0 const RequestAction requestAction = RequestAction.Create; // nr. != 0 // Act var action = labelAction.ParseEnumValue <RequestAction>(); // Assert action.ShouldBeEquivalentTo(requestAction); }
public Task <byte[]> Request(byte[] request, int timeout, CancellationTokenSource source) { RequestAction?.Invoke(); ServerRequest = request; ServerTimeout = timeout; Source = source; if (ServerError != null) { throw ServerError; } return(Task.FromResult(ServerResponse)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = string.Empty; switch (RequestAction.ToLower()) { case "custhistorylogexternalsubmit": CustHistoryLogExternalSubmit(out msg); //外部提交 break; } context.Response.Write(msg); }
private async Task SendBuildRequest(Unit buildingUnit, int unitType) { var action = new Action(); action.ActionRaw = new ActionRaw(); action.ActionRaw.UnitCommand = new ActionRawUnitCommand(); action.ActionRaw.UnitCommand.AbilityId = _gameDataService.GetAbilityId(unitType); action.ActionRaw.UnitCommand.UnitTags.Add(buildingUnit.Tag); var requestAction = new RequestAction(); requestAction.Actions.Add(action); // ActionService? Can send multiple actions in one request await _connectionService.SendRequestAsync(new Request { Action = requestAction }); // Queue a list desired prioritised actions, that trigger when possible (unit queue is close to finished and resources are sufficient) }
public async Task <IActionResult> PostRequestAction([FromBody] RequestAction requestAction) { string sRequestStatus = null; Request request; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!UsertExists(requestAction.Username)) { return(BadRequest("User does not exist.")); } if (!RequestExists(requestAction.RequestId)) { return(BadRequest("Request does not exist.")); } if (!RequestActions.IsValidAction(requestAction.Action)) { return(BadRequest("Request Action does not exist.")); } if (requestAction.Action == RequestActions.DB_APPROVE) { sRequestStatus = RequestStates.DB_APPROVED; } else if (requestAction.Action == RequestActions.DB_REJECT) { sRequestStatus = RequestStates.DB_REJECED; } _context.RequestActions.Add(requestAction); request = await _context.Requests.FindAsync(requestAction.RequestId); if (sRequestStatus != null) { request.State = sRequestStatus; _context.Requests.Update(request); } await _context.SaveChangesAsync(); return(CreatedAtAction("GetRequestAction", new { id = requestAction.RequestId }, requestAction)); }
private async Task SendAttackRequest(Unit unit, Point2D point) { var action2 = new Action(); action2.ActionRaw = new ActionRaw(); action2.ActionRaw.UnitCommand = new ActionRawUnitCommand(); action2.ActionRaw.UnitCommand.AbilityId = 23; // Attack abilitiy action2.ActionRaw.UnitCommand.UnitTags.Add(unit.Tag); action2.ActionRaw.UnitCommand.TargetWorldSpacePos = point; var requestAction = new RequestAction(); requestAction.Actions.Add(action2); await _connectionService.SendRequestAsync(new Request { Action = requestAction }); }
public ResultJson AddOrUpdateAction(RequestAction request) { if (string.IsNullOrEmpty(request.Controller)) { result.Message = "Nombre del controlador no es valido, "; } if (string.IsNullOrEmpty(request.Action)) { result.Message += "Nombre de la accion no es valido, "; } if (string.IsNullOrEmpty(request.Name)) { result.Success = false; result.Message += "Nombre del SubMenu no es valido"; return(result); } using (ApplicationDbContext db = new ApplicationDbContext()) { var subMenu = db.SubMenu.Where(s => s.Name == request.Name).FirstOrDefault(); if (subMenu == null) { SubMenu sub = new SubMenu() { IdMenu = request.IdMenu, Name = request.Name, ControllerName = request.Controller, ActionName = request.Action, IsActive = request.IsActive, CreationDate = DateTime.Now, }; db.SubMenu.Add(sub); db.SaveChanges(); } else { subMenu.Name = request.Name; subMenu.ControllerName = request.Controller; subMenu.ActionName = request.Action; subMenu.IsActive = request.IsActive; db.Entry(subMenu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } return(result); }
/// <summary> /// Sets the API action. /// </summary> /// <param name="action">The action.</param> private void SetApiAction(RequestAction action) { string apiValue; switch (action) { case RequestAction.Authorize: apiValue = "auth"; break; case RequestAction.Settle: apiValue = "capture"; break; case RequestAction.Sale: apiValue = "sale"; break; case RequestAction.Refund: apiValue = "refund"; break; case RequestAction.Void: apiValue = "void"; break; default: apiValue = "auth"; break; } Queue(Charge1Api.TransactionType, apiValue); ApiAction = action; }
/// <summary> /// Sets the API action. /// </summary> /// <param name="action">The action.</param> private void SetApiAction(RequestAction action) { var apiValue = "AUTH_CAPTURE"; ApiAction = action; switch (action) { case RequestAction.Authorize: apiValue = "AUTH_ONLY"; break; case RequestAction.Settle: apiValue = "PRIOR_AUTH_CAPTURE"; break; case RequestAction.Refund: apiValue = "CREDIT"; break; case RequestAction.Void: apiValue = "VOID"; break; } Queue(AuthorizeDotNetApi.TransactionType, apiValue); }
/// <summary> /// Initializes a new instance of the <see cref="GatewayRequest"/> class. /// </summary> public GatewayRequest () { Post = new NameValueCollection(); _post = new StringBuilder(); LoadCoreValues(); _apiAction = RequestAction.AuthorizeAndCapture; }
public void SendNotify(Event notifiedEvent, RequestAction action,NotifyReceiversList receiversList,object tag=null) { MiniSplash_TF sp0 = new MiniSplash_TF(Properties.Resources.load4) {Text=@"Отправка сообщения" , StatusText = @"Отправка почтового уведомления"}; sp0.WorkingFunction = () => { ClearHeaders(); List<string> fullReceivers = new List<string>(); List<string> shortReceivers = new List<string>(); if (receiversList != null) { List<NotifyReceiver> receivers = receiversList.NotifyReceivers.ToList(); receivers.ForEach(r => { if (r.Required) r.Selected = true; }); var selectedReceivers = receivers.Where(r => r.Selected).ToList(); if (selectedReceivers.Count == 0) return; fullReceivers = selectedReceivers.Where(r => !r.IsSms).Select(r => r.Receiver).ToList(); shortReceivers = selectedReceivers.Where(r => r.IsSms).Select(r => r.Receiver).ToList(); } else { if (tag != null) { var data = tag as string[]; if (data != null) { fullReceivers.Add(data[0]); if (data.Length == 2) shortReceivers.Add(data[1]); } } } string shortDepartmentId = string.Empty; if (notifiedEvent.Access_Users.Department != null) if (notifiedEvent.Access_Users.Department.ShortId != string.Empty) shortDepartmentId = notifiedEvent.Access_Users.Department.ShortId.Trim() + ";"; string eventNumber = @"#" + notifiedEvent.Number; string eventTypeDescription = ((EventType) notifiedEvent.Type).GetAttributeValue<DescriptionAttribute, string>(x => x.Description); string eventIndex = notifiedEvent.EventIndex.ToString(); int customerId = notifiedEvent.CustomerId.HasValue ? notifiedEvent.CustomerId.Value : 0; int firmId = notifiedEvent.FirmId.HasValue ? notifiedEvent.FirmId.Value : 0; string[] customerInfo = _dataContexts.GetCustomerDescription2(firmId, customerId); string eventCustomerFull = string.Join(",", customerInfo); string fullEventText = string.Empty; string shortEventText = string.Empty; string fullEmailSubject = string.Empty; string shortEmailSubject = string.Empty; string eventCustomerSide = string.Empty; string eventCustomerPort = string.Empty; string eventCustomerPortShort = string.Empty; if (notifiedEvent.CustomerSide != null) { eventCustomerSide = notifiedEvent.CustomerSide.Description; if (notifiedEvent.EquipmentPort != null) { eventCustomerPort = GetPortFullDescription(notifiedEvent.EquipmentPort); eventCustomerPortShort = GetPortShortDescription(notifiedEvent.EquipmentPort); } } else { if (notifiedEvent.EquipmentPort != null) { if (notifiedEvent.EquipmentPort.SideLink.LinkType == (int) SideLinkType.toEquipmentPort) eventCustomerPort = GetPortFullDescription(notifiedEvent.EquipmentPort.SideLink.EquipmentPort); eventCustomerSide = notifiedEvent.EquipmentPort.Equipment.Area.Description; eventCustomerPortShort = GetPortShortDescription(notifiedEvent.EquipmentPort); } } string eventCustomerContact = notifiedEvent.CustomerInfo; string eventDescription = notifiedEvent.Description; switch (action) { case RequestAction.Transfer: { var user = notifiedEvent.Access_Users; if (user == null) return; fullEmailSubject = @"Номер заявки: " + eventNumber + @" изменена"; fullEventText = @"Заявка: " + eventNumber + " передана в департамент [" + user.Department.Description + "]"; //+ @"Тип заявки: " + eventTypeDescription + Environment.NewLine //+ @"Вес заявки: " + eventIndex + Environment.NewLine //+ @"Абонент: " + eventCustomerFull + Environment.NewLine //+ (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") //+ (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") //+ @"Контакт абонента: " + eventCustomerContact + Environment.NewLine //+ @"Текст заявки: " + eventDescription; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@transfer.event>")); break; } case RequestAction.Renew: case RequestAction.New: { fullEventText = @"Номер заявки: " + eventNumber + @" Новая заявка" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Вес заявки: " + eventIndex + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Контакт абонента: " + eventCustomerContact + Environment.NewLine + @"Текст заявки: " + eventDescription; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); shortEventText = eventNumber + ";NEW;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + eventCustomerSide + ";" + eventDescription + ";" + customerInfo.Last(); shortEmailSubject = ""; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Edit: break; case RequestAction.Remedy: { string remedyPerson = string.Empty; string remedyData = string.Empty; if (tag != null) { var data = tag as string[]; if (data != null) { remedyPerson = data[0]; remedyData = data[1]; } } fullEventText = @"Номер заявки: " + eventNumber + @" Изменено состояние" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Вес заявки: " + eventIndex + Environment.NewLine + @"Устранил: " + remedyPerson + @" Выполнены работы: " + remedyData + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Текст заявки: " + eventDescription; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); shortEventText = eventNumber + ";REMEDY;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + (eventCustomerSide) + ";" + remedyPerson + ";" + remedyData + ";" + eventDescription + ";" + customerInfo.Last(); shortEmailSubject = ""; _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@remedy.event>")); _headers.Add(new KeyValuePair<string, string>("References", "<" + notifiedEvent.Id.ToString() + "@open.event>")); _headers.Add(new KeyValuePair<string, string>("In-Reply-To", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Close: { string closedPerson = notifiedEvent.Access_Users2 != null ? notifiedEvent.Access_Users2.Description : string.Empty; string checkPerson = notifiedEvent.Access_Users1 != null ? notifiedEvent.Access_Users1.Description : string.Empty; string closedDate = notifiedEvent.CloseDate.HasValue ? notifiedEvent.CloseDate.Value.ToShortDateString() : string.Empty; string closedFixer = notifiedEvent.ClosePerson; string closedCheckDate = notifiedEvent.CheckDate.HasValue ? notifiedEvent.CheckDate.Value.ToShortDateString() : string.Empty; fullEmailSubject = eventNumber + ", " + eventCustomerFull + (!string.IsNullOrEmpty(eventCustomerSide) ? ", " + eventCustomerSide : ""); fullEventText = @"Номер заявки: " + eventNumber + @" Закрытие заявки" + Environment.NewLine + @"Тип заявки: " + eventTypeDescription + Environment.NewLine + @"Абонент: " + eventCustomerFull + Environment.NewLine + (!string.IsNullOrEmpty(eventCustomerSide) ? @"Площадка абонента: " + eventCustomerSide + Environment.NewLine : "") + (!string.IsNullOrEmpty(eventCustomerPort) ? @"Порт абонента: " + eventCustomerPort + Environment.NewLine : "") + @"Закрыл: " + closedPerson + " " + closedDate + Environment.NewLine + @"Проверил: " + checkPerson + " " + closedDate + Environment.NewLine + @"Исполнитель: " + closedFixer + " " + closedCheckDate + Environment.NewLine + @"Отчет: " + notifiedEvent.CloseInfo; shortEventText = eventNumber + ";CLOSE;" + shortDepartmentId + customerId + ";" + eventIndex + ";" + eventCustomerSide + ";" + closedPerson + ";" + eventDescription + ";" + customerInfo.Last(); _headers.Add(new KeyValuePair<string, string>("Message-ID", "<" + notifiedEvent.Id.ToString() + "@close.event>")); _headers.Add(new KeyValuePair<string, string>("References", "<" + notifiedEvent.Id.ToString() + "@open.event>")); _headers.Add(new KeyValuePair<string, string>("In-Reply-To", "<" + notifiedEvent.Id.ToString() + "@open.event>")); break; } case RequestAction.Unknown: break; default: throw new ArgumentOutOfRangeException("action"); } if (fullReceivers.Any()) { try { if (!string.IsNullOrEmpty(fullEventText)) { string emailFrom = @"*****@*****.**"; if (SharedAppData.LoggedUser.Email != null && !string.IsNullOrEmpty(SharedAppData.LoggedUser.Email)) { emailFrom = SharedAppData.LoggedUser.Email; } SendEmail(_headers, fullReceivers, emailFrom, fullEmailSubject, fullEventText); } } catch (Exception) { throw; } } if (shortReceivers.Any()) { try { if (!string.IsNullOrEmpty(shortEventText)) { shortEventText = Translator.ToTranslite(shortEventText); shortReceivers.ForEach(receiver => { MailMessage mailMessage = new MailMessage {From = new MailAddress("*****@*****.**"), Subject = shortEmailSubject, Body = shortEventText}; mailMessage.Headers.Add("Return-Path", "*****@*****.**"); mailMessage.Headers.Add("X-Original-To", "*****@*****.**"); mailMessage.Headers.Add("X-Mailer", "event registrator"); mailMessage.ReplyToList.Add("*****@*****.**"); mailMessage.To.Add(receiver); SmtpClient client = new SmtpClient("212.90.160.3") {EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network}; client.Send(mailMessage); mailMessage.Dispose(); }); } } catch (Exception) { throw; } } }; sp0.ShowDialog(_parentForm); }