Esempio n. 1
0
        public string executeAlertWorkflowProcess(string deviceName, string alertID, string message)
        {
            try
            {
                string          path        = "https://www.appiyo.com/d/workflows/b8160bfe4f9211e49946bc305bdda218/execute?projectId=9eab43004f9211e49946bc305bdda218";
                CookieContainer cookieStore = new CookieContainer();
                cookieStore.SetCookies(new Uri(path), authToken);
                Dictionary <string, string> alertDictionary = new Dictionary <string, string>();

                int[] arrayesc  = new int[1];
                int[] custarray = new int[1];
                //user id json array
                MeonMembers meonmem      = new MeonMembers();
                var         MeoncustList = GetCustomerList();

                //  meonmem.custID = "301";
                if (MeoncustList != null)
                {
                    if (MeoncustList.Count > 0)
                    {
                        custarray = new int[MeoncustList.Count];
                        int i = 0;

                        foreach (var meoncust in MeoncustList)
                        {
                            custarray[i] = Int32.Parse(meoncust.CustomerID);
                            i++;
                        }
                    }
                    else
                    {
                        custarray[0] = 0;
                    }
                }
                else
                {
                    custarray[0] = 0;
                }
                //escallation userid json arrtt

                EscMeonMembers MeonEscCustObj  = new EscMeonMembers();
                var            MeonEscCustList = GetEscallateCustomerList();
                if (MeonEscCustList != null)
                {
                    if (MeonEscCustList.Count > 0)
                    {
                        arrayesc = new int[MeonEscCustList.Count];
                        int j = 0;

                        foreach (var meonesccust in MeonEscCustList)
                        {
                            arrayesc[j] = Int32.Parse(meonesccust.CustomerID);
                            j++;
                        }
                    }
                    else
                    {
                        arrayesc[0] = 0;
                    }
                }
                else
                {
                    arrayesc[0] = 0;
                }

                //AMS.Broker.WatchDogService.Services.MeonCloudService meonObj = new AMS.Broker.WatchDogService.Services.MeonCloudService();
                //string meonAuthToken = meonObj.login(Storage.MeonUsername, Storage.MeonPassword);

                Alertdetails Obj = new Alertdetails();
                Obj.id               = alertID;
                Obj.alertId          = alertID;
                Obj.severity         = "Medium";
                Obj.device           = "" + deviceName;
                Obj.message          = message;
                Obj.mailId           = "*****@*****.**";
                Obj.escalationMailId = "*****@*****.**";
                Obj.toGroupId        = "544dd6e658bd6c48191ceca9";// "5454b3f3c00df250d08080c8";
                Obj.toUser           = "******";
                //Obj.mocAuthToken = meonAuthToken.Substring(meonAuthToken.IndexOf("=") + 1);
                Obj.userIds           = custarray;
                Obj.escalationUserIds = arrayesc;
                // string strData = JsonSerializer<Alertdetails>(Obj);


                Alertdetails1 Obj1 = new Alertdetails1();
                Obj1.processId        = alertProcessId;
                Obj1.ProcessVariables = Obj;
                Obj1.workflowId       = workflowId;
                Obj1.projectId        = projectId;



                // List<tblMeonMembersDTO> MeonEscCustList = new List<tblMeonMembersDTO>();


                //   string meonUserIDs = JsonSerializer<MeonMember>(MeonCustObj);//JsonConvert.SerializeObject(MeonUser, Formatting.Indented);

                //   string EscMeonUserIDs = JsonSerializer<MeonMember>(MeonEscCustObj);

                string strData1 = JsonSerializer <Alertdetails1>(Obj1);

                var content = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("id", alertProcessId),
                    new KeyValuePair <string, string>("processVariables", strData1.ToString()),
                    //  new KeyValuePair<string, string>("userIds", meonUserIDs.ToString()),
                    //  new KeyValuePair<string, string>("escalationUserIds", EscMeonUserIDs.ToString()),
                    //  new KeyValuePair<string, string>("mocAuthToken", AuthToken)
                };

                HttpContent requestParams = new FormUrlEncodedContent(content);
                var         handler       = new HttpClientHandler
                {
                    CookieContainer       = cookieStore,
                    UseCookies            = true,
                    UseDefaultCredentials = false
                };

                HttpClient client = new HttpClient(handler);

                HttpResponseMessage httpMethod = client.PutAsync(new Uri(path), requestParams).Result;
                string responseFromServer      = httpMethod.Content.ReadAsStringAsync().Result;
                if (responseFromServer.Contains("status"))
                {
                }
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
Esempio n. 2
0
        public string executeCloseWorkflow(string alertID, string message)
        {
            try
            {
                string          path        = "https://www.appiyo.com/d/workflows/b8160bfe4f9211e49946bc305bdda218/execute?projectId=9eab43004f9211e49946bc305bdda218";
                CookieContainer cookieStore = new CookieContainer();
                cookieStore.SetCookies(new Uri(path), authToken);
                Dictionary <string, string> alertDictionary = new Dictionary <string, string>();

                //    Obj.severity = "Medium";
                //  Obj.device = "D1";
                // Obj.message = message;
                //Obj.mailId = "*****@*****.**";
                ///Obj.escalationMailId = "*****@*****.**";
                ///Obj.toGroupId = "5454b3f3c00df250d08080c8";
                //Obj.toUser = "******";
                //

                /*   int[] arrayesc = new int[1];
                 * int[] custarray = new int[1];
                 * //user id json array
                 * MeonMembers meonmem = new MeonMembers();
                 * var MeoncustList = GetCustomerList();
                 *
                 * //  meonmem.custID = "301";
                 * if (MeoncustList != null)
                 * {
                 *     if (MeoncustList.Count > 0)
                 *     {
                 *         custarray = new int[MeoncustList.Count];
                 *         int i = 0;
                 *
                 *         foreach (var meoncust in MeoncustList)
                 *         {
                 *             custarray[i] = Int32.Parse(meoncust.CustomerID);
                 *             i++;
                 *         }
                 *     }
                 *     else
                 *     {
                 *         custarray[0] = 0;
                 *     }
                 * }
                 * else
                 * {
                 *     custarray[0] = 0;
                 * }
                 * //escallation userid json arrtt
                 *
                 * EscMeonMembers MeonEscCustObj = new EscMeonMembers();
                 * var MeonEscCustList = GetEscallateCustomerList();
                 * if (MeonEscCustList != null)
                 * {
                 *     if (MeonEscCustList.Count > 0)
                 *     {
                 *         arrayesc = new int[MeonEscCustList.Count];
                 *         int j = 0;
                 *
                 *         foreach (var meonesccust in MeonEscCustList)
                 *         {
                 *             arrayesc[j] = Int32.Parse(meonesccust.CustomerID);
                 *             j++;
                 *         }
                 *     }
                 *     else
                 *     {
                 *         arrayesc[0] = 0;
                 *     }
                 * }
                 * else
                 * {
                 *     arrayesc[0] = 0;
                 * }
                 *
                 * AMS.Broker.WatchDogService.Services.MeonCloudService meonObj = new AMS.Broker.WatchDogService.Services.MeonCloudService();
                 * string AuthToken = meonObj.login(Storage.MeonUsername, Storage.MeonPassword);
                 */
                //
                Alertdetails Obj = new Alertdetails();
                Obj.alertId = alertID;
                //   Obj.userIds = custarray;
                //   Obj.escalationUserIds = arrayesc;

                string        strData = JsonSerializer <Alertdetails>(Obj);
                Alertdetails1 Obj1    = new Alertdetails1();
                Obj1.processId        = ackProcessId;
                Obj1.ProcessVariables = Obj;
                Obj1.workflowId       = workflowId;
                Obj1.projectId        = projectId;


                string strData1 = JsonSerializer <Alertdetails1>(Obj1);


                var content = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("id", ackProcessId),
                    new KeyValuePair <string, string>("processVariables", strData1.ToString()),
                };


                HttpContent requestParams = new FormUrlEncodedContent(content);
                var         handler       = new HttpClientHandler
                {
                    CookieContainer       = cookieStore,
                    UseCookies            = true,
                    UseDefaultCredentials = false
                };

                HttpClient          client     = new HttpClient(handler);
                HttpResponseMessage httpMethod = client.PutAsync(new Uri(path), requestParams).Result;
                string responseFromServer      = httpMethod.Content.ReadAsStringAsync().Result;
                if (responseFromServer.Contains("Status"))
                {
                }
            }
            catch (Exception ex)
            {
            }
            return(null);
        }