Пример #1
0
        /// <summary>
        /// Creates a cStatus object. It will be saved in permanent storage only
        /// on calling Save()
        /// </summary>
        /// <returns>cStatus object</returns>
        public static cStatus Create()
        {
            cStatus oObj = new cStatus();

            SecurityCheck((int)enStatus_Action.Create);

            // Create an object in memory, will be saved to storage on calling Save()
            oObj.m_bCreating = true;
            oObj.m_bInvalid  = false;
            return(oObj);
        }
Пример #2
0
        /// <summary>
        /// Ensures that an object with the specified name exists, while creating other properties are set to their default values
        /// </summary>
        /// <param name="i_sName">Name</param>
        /// <returns>cStatus object</returns>
        public static cStatus CreateIfRequiredAndGet(string i_sName)
        {
            cStatus oObj = cStatus.Get_Name(i_sName);

            if (oObj == null)
            {
                oObj       = cStatus.Create();
                oObj.sName = i_sName;
                oObj.Save();
            }
            return(oObj);
        }
        public async Task <cStatus> GetfcmsubcriptioncheckAsync(string DeviceID)
        {
            cStatus       st         = new cStatus();
            FCMController fcm        = new FCMController();
            ctblFCM       fcmDetails = new ctblFCM();

            fcmDetails = (ctblFCM)fcm.GetctblFCM(1);

            string uri;

            //uri = "https://iid.googleapis.com/iid/info/f0l3VKFi_bs:APA91bEvLlgSHIwB3zJv3YEL_jkjxXRVzWY85jNe4_6tSC-IE7oh-FqJBajA9nuDNI7pZCZ1eqa2aDjCCpK9bS7jW0ONezffGvRMs7q4lbyVGEYkKLv4tH9wE26b80aSLM5sdowG349G?details=true";
            uri = "https://iid.googleapis.com/iid/info/" + DeviceID + "?details=true";

            try
            {
                var client  = new RestClient(uri);
                var request = new RestRequest(Method.GET);

                request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY));
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY));


                IRestResponse <cFCMSubscribed> asyncHandle = await client.ExecuteGetTaskAsync <cFCMSubscribed>(request);

                //return asyncHandle.Content.ToString();
                st.DesctoDev = asyncHandle.Content.ToString();
                if (st.DesctoDev.Contains("THANDORA_ADMIN") && st.DesctoDev.Contains("INDIA"))
                {
                    st.StatusMsg = "THANDORA Installed successfully";
                    st.StatusID  = 0;
                }
                else
                {
                    st.StatusMsg = "THANDORA Installation failed. Please install it again. ";
                    st.StatusID  = 1;
                }
                return(st);
            }
            catch (Exception ex)
            {
                st.StatusID  = 1;//  Notification failure
                st.StatusMsg = ex.Message.ToString();
                return(st);
            }
        }
Пример #4
0
        /// <summary>
        /// Finds and return cStatus objects matching the specified criteria
        /// </summary>
        /// <param name="i_oFilter">Filter criteria (WHERE clause)</param>
        /// <returns>cStatus objects</returns>
        public static List <cStatus> Find(cFilter i_oFilter)
        {
            DataTable      dt = Find_DataTable(i_oFilter, null);
            List <cStatus> l  = new List <cStatus>();
            cStatus        oObj;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                oObj                   = new cStatus();
                oObj.m_iID             = Convert.ToInt32(dt.Rows[i]["iID"]);
                oObj.m_sName           = dt.Rows[i]["sName"].ToString();
                oObj.m_dtCreatedOn     = Convert.ToDateTime(dt.Rows[i]["dtCreatedOn"]);
                oObj.m_dtLastUpdatedOn = Convert.ToDateTime(dt.Rows[i]["dtLastUpdatedOn"]);

                oObj.m_bIsActive = Convert.ToBoolean(dt.Rows[i]["bIsActive"]);
                oObj.m_bInvalid  = false;
                l.Add(oObj);
            }
            return(l);
        }
Пример #5
0
        public async Task <cStatus> getVersion()
        {
            cStatus status = new cStatus();


            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_get_version", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@version", SqlDbType.NVarChar, 5);
                    cmd.Parameters["@version"].Direction = ParameterDirection.Output;


                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();


                    status.StatusMsg = cmd.Parameters["@version"].Value.ToString();
                    status.StatusID  = 0;


                    //status.returnID = int.Parse(retvalue);
                }
            }
            catch (Exception ex)
            {
                status.StatusMsg = ex.Message.ToString();
                status.StatusID  = 1;
            }
            return(status);
        }
        public async Task <cStatus> NewTellerNotificationAsync(string GroupName, string TellerName, string TellerService, int senderID)
        {
            string        toGroup, uri;
            cStatus       st         = new cStatus();
            FCMController fcm        = new FCMController();
            ctblFCM       fcmDetails = new ctblFCM();

            fcmDetails = (ctblFCM)fcm.GetctblFCM(1);

            var value = "New TELLER:" + TellerService;

            uri     = "https://fcm.googleapis.com/fcm/send";
            toGroup = "/topics/" + GroupName;

            try
            {
                var client  = new RestClient(uri);
                var request = new RestRequest(Method.POST);

                request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY));
                request.AddHeader("content-type", "application/json");
                request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY));

                var postData = new
                {
                    //registration_ids = deviceids,
                    //to=devicegroup,
                    //to= "ckZ8rtZ6r1I:APA91bHvdVlS7p7-XdQMWAVI1zpG6LfU40Mrllj9u2wRtGhnQ-GUPk43BjtfsDadoJmYviCsn1mMluXaJfWrldLWLccddgAE1cUVIbVP1a7JSo3IIlraZoi4qipt8v-1owIavTniwahd",
                    to   = toGroup,
                    data = new
                    {
                        title            = " available in THANDORA",
                        message          = TellerName + " joined in Thandora as " + TellerService,
                        SenderName       = TellerName,
                        imageUrl         = "",
                        messageId        = senderID,
                        SenderID         = senderID,
                        notificationType = 4  //(1->PostMessage, 2-- > Comment, 3 --> Enquiry, 4 -> New Teller and so on)
                    },
                    priority = "high",

                    /* data = new
                     * {
                     *   MessageID = 1
                     * },*/

                    /*notification = new
                     * {
                     *  body = TellerName + " joined in Thandora as " + TellerService,
                     *  title = TellerName + " using THANDORA",
                     *  icon = "myicon"
                     * }*/
                };


                var serializer = new JavaScriptSerializer();
                var json       = serializer.Serialize(postData);

                //request.AddParameter("application/json", "{\r\n                \"to\" : \""+DeviceID+"\"\r\n                \"data\":{\r\n                \t \"enquiryID\": "+enquiryid.ToString()+"\r\n                }\r\n                \r\n                \"notification\":\r\n                {\r\n                    \"body\": \""+enquirymessage+"\",\r\n                    \"title\":\""+FromUser +"\",\r\n                    \"icon\": \"myicon\"\r\n                }\r\n            }", ParameterType.RequestBody);

                //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new
                // { body = enquirymessage, title = FromUser,icon = "myicon"  } }) , ParameterType.RequestBody);

                request.AddParameter("application/json", json, ParameterType.RequestBody);

                /*var rs = client.Execute(request);
                 * sResponseFromServer = rs.Content.ToString();
                 * return sResponseFromServer;*/
                //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete);

                IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request);

                //return asyncHandle.Content.ToString();
                st.DesctoDev = asyncHandle.Content.ToString();
                st.returnID  = asyncHandle.Data.success; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE
                st.StatusID  = asyncHandle.Data.failure; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE
                //return asyncHandle.Data.success.ToString();
                return(st);
            }
            catch (Exception ex)
            {
                st.StatusID  = 1;
                st.StatusMsg = ex.Message.ToString();
                return(st);
            }
        }
        public async Task PostMessageforEachDeviceAsync(string titlebroadcast, string DeviceID, string SenderName, string msgCategory, string message, string imgPath, int MsgID, int senderID)
        {
            string        uri;
            cStatus       st         = new cStatus();
            FCMController fcm        = new FCMController();
            ctblFCM       fcmDetails = new ctblFCM();

            fcmDetails = (ctblFCM)fcm.GetctblFCM(1);
            string value;

            if (message.Length > 50)
            {
                value = message.Substring(0, 40) + "...";
            }
            else
            {
                value = message;
            }


            uri = "https://fcm.googleapis.com/fcm/send";


            /* if (SenderName.Equals("THANDORA ADMIN") == true)
             * {
             *   toGroup = "/topics/THANDORA_ADMIN";
             * }
             * else
             * {
             *   toGroup = "/topics/" + GroupName;
             * }
             */
            try
            {
                var client  = new RestClient(uri);
                var request = new RestRequest(Method.POST);

                request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY));
                request.AddHeader("content-type", "application/json");
                request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY));
                var postData = new
                {
                    //registration_ids = deviceids,
                    //to=devicegroup,
                    //to= "ckZ8rtZ6r1I:APA91bHvdVlS7p7-XdQMWAVI1zpG6LfU40Mrllj9u2wRtGhnQ-GUPk43BjtfsDadoJmYviCsn1mMluXaJfWrldLWLccddgAE1cUVIbVP1a7JSo3IIlraZoi4qipt8v-1owIavTniwahd",
                    //to = toGroup,
                    to   = DeviceID,
                    data = new
                    {
                        title            = titlebroadcast + "/" + msgCategory,
                        message          = value,
                        SenderName       = SenderName,
                        imageUrl         = imgPath,
                        messageId        = MsgID,
                        SenderID         = senderID,
                        notificationType = "1"  //(1->PostMessage, 2-- > EnquiryReply and so on)
                    },
                    priority = "high"

                               /*notification = new
                                * {
                                *  body = value,
                                *  title = titlebroadcast + "/" + msgCategory + "/" + SenderName,
                                *  icon = "myicon"
                                * }*/
                };

                var serializer = new JavaScriptSerializer();
                var json       = serializer.Serialize(postData);

                //request.AddParameter("application/json", "{\r\n                \"to\" : \""+DeviceID+"\"\r\n                \"data\":{\r\n                \t \"enquiryID\": "+enquiryid.ToString()+"\r\n                }\r\n                \r\n                \"notification\":\r\n                {\r\n                    \"body\": \""+enquirymessage+"\",\r\n                    \"title\":\""+FromUser +"\",\r\n                    \"icon\": \"myicon\"\r\n                }\r\n            }", ParameterType.RequestBody);

                //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new
                // { body = enquirymessage, title = FromUser,icon = "myicon"  } }) , ParameterType.RequestBody);

                request.AddParameter("application/json", json, ParameterType.RequestBody);

                /*var rs = client.Execute(request);
                 * sResponseFromServer = rs.Content.ToString();
                 * return sResponseFromServer;*/
                //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete);

                IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request);

                //return asyncHandle.Content.ToString();
                st.DesctoDev = asyncHandle.Content.ToString();
                st.returnID  = asyncHandle.Data.success; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE
                st.StatusID  = asyncHandle.Data.failure; // TOPIC DISTIBUTION WONT RETURN SUCCESS OR FAILURE
                //return asyncHandle.Data.success.ToString();
            }
            catch (Exception ex)
            {
                st.StatusID  = 1;//  Notification failure
                st.StatusMsg = ex.Message.ToString();
            }
        }
Пример #8
0
        private void mnuExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvStatus.SelectedItems.Count == 0)
                {
                    tsslblMsg.Text = "Nenhum registro foi selecionado";
                    return;
                }

                cStatus cs = new cStatus();
                cs.id_status = Convert.ToInt32(lvStatus.SelectedItems[0].Text);
                cs.status    = lvStatus.SelectedItems[0].SubItems[1].Text;

                DialogResult dlr = (MessageBox.Show(string.Concat("Deseja realmente exclui o status:\n", lvStatus.SelectedItems[0].SubItems[1].Text, "?"), "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question));
                if (dlr == DialogResult.Yes)
                {
                    if (!cs.exclui_status(cs))
                    {
                        MessageBox.Show("Registro excluído com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        #region LOG
                        cLog lg = new cLog();
                        lg.log = string.Concat("Exclusão de Registro.", Environment.NewLine,
                                               "Status: ", cs.status.ToUpper()
                                               );
                        lg.form        = this.Text;
                        lg.metodo      = sender.ToString();
                        lg.dt          = DateTime.Now;
                        lg.usersistema = cGlobal.userlogado;
                        lg.userRede    = Environment.UserName;
                        lg.terminal    = Environment.MachineName;
                        lg.tp_flag     = true;
                        lg.grava_log(lg);
                        #endregion
                        inicio();
                    }
                    else
                    {
                        MessageBox.Show("O registro não pode ser excluído,\npois contém EVENTOS vínculados a ele.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        inicio();
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                #region LOG ERRO
                cLog lg = new cLog();
                lg.log         = ex.Message.Replace("'", "");
                lg.form        = this.Text;
                lg.metodo      = sender.ToString();
                lg.dt          = DateTime.Now;
                lg.usersistema = cGlobal.userlogado;
                lg.userRede    = Environment.UserName;
                lg.terminal    = Environment.MachineName;
                lg.tp_flag     = false;
                lg.grava_log(lg);
                #endregion
            }
        }
Пример #9
0
        public async Task <IHttpActionResult> PostctblSender([FromBody] ctblSender ctblSender)
        {
            cStatus status = new cStatus();
            string  retvalue;

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_new_sender", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter paramSendName = new SqlParameter();
                    paramSendName.ParameterName = "@SenderName";
                    paramSendName.Value         = ctblSender.SenderName;
                    cmd.Parameters.Add(paramSendName);

                    SqlParameter paramSenderPhone = new SqlParameter();
                    paramSenderPhone.ParameterName = "@SenderPhone";
                    paramSenderPhone.Value         = ctblSender.SenderPhone;
                    cmd.Parameters.Add(paramSenderPhone);

                    if (ctblSender.deviceTokenID == null)
                    {
                        ctblSender.deviceTokenID = "Assigned by API";

                        /* status.StatusID = 1;
                         * status.DesctoDev = "FCM Device id null ";
                         * status.StatusMsg = " FCM Device id null ";
                         * return Ok(status);*/
                    }

                    SqlParameter paramdeviceTokenID = new SqlParameter();
                    paramdeviceTokenID.ParameterName = "@IME";
                    paramdeviceTokenID.Value         = ctblSender.deviceTokenID;
                    cmd.Parameters.Add(paramdeviceTokenID);


                    SqlParameter paramRecSIMNO = new SqlParameter();
                    paramRecSIMNO.ParameterName = "@SIMNO";
                    paramRecSIMNO.Value         = ctblSender.SIMNO;
                    cmd.Parameters.Add(paramRecSIMNO);

                    SqlParameter paramSenderContactNo_1 = new SqlParameter();
                    paramSenderContactNo_1.ParameterName = "@SenderContactNo_1";
                    paramSenderContactNo_1.Value         = ctblSender.SenderContactNo_1;
                    cmd.Parameters.Add(paramSenderContactNo_1);

                    /* SqlParameter paramSenderContactNo_2 = new SqlParameter();
                     * paramSenderContactNo_2.ParameterName = "@SenderContactNo_2";
                     * paramSenderContactNo_2.Value = ctblSender.SenderContactNo_2;
                     * cmd.Parameters.Add(paramSenderContactNo_2);
                     */

                    SqlParameter paramContactHide = new SqlParameter();
                    paramContactHide.ParameterName = "@ContactHide";
                    paramContactHide.Value         = ctblSender.ContactHide;
                    cmd.Parameters.Add(paramContactHide);

                    SqlParameter paramcServiceType = new SqlParameter();
                    paramcServiceType.ParameterName = "@cServiceType";
                    paramcServiceType.Value         = ctblSender.cServiceType;
                    cmd.Parameters.Add(paramcServiceType);

                    SqlParameter paramServiceDesc = new SqlParameter();
                    paramServiceDesc.ParameterName = "@ServiceDesc";
                    if (ctblSender.ServiceDesc == null)
                    {
                        ctblSender.ServiceDesc = " ";
                    }
                    paramServiceDesc.Value = ctblSender.ServiceDesc;
                    cmd.Parameters.Add(paramServiceDesc);

                    SqlParameter paramPOSTCODE = new SqlParameter();
                    paramPOSTCODE.ParameterName = "@POSTCODE";
                    paramPOSTCODE.Value         = ctblSender.POSTCODE;
                    cmd.Parameters.Add(paramPOSTCODE);

                    SqlParameter paramAddress = new SqlParameter();
                    paramAddress.ParameterName = "@Address";
                    if (ctblSender.Address == null)
                    {
                        ctblSender.Address = " ";
                    }
                    paramAddress.Value = ctblSender.Address;
                    cmd.Parameters.Add(paramAddress);

                    SqlParameter paramlogopath = new SqlParameter();
                    paramlogopath.ParameterName = "@logopath";
                    paramlogopath.Value         = ctblSender.logopath;
                    cmd.Parameters.Add(paramlogopath);

                    cmd.Parameters.Add("@LastInsertedID", SqlDbType.Int);
                    cmd.Parameters["@LastInsertedID"].Direction = ParameterDirection.Output;

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    //retvalue = cmd.Parameters["@LastInsertedID"].Value.ToString();
                    retvalue        = cmd.Parameters["@LastInsertedID"].Value.ToString();
                    status.returnID = int.Parse(retvalue);
                    if (status.returnID == -5)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = " Name Restricted ";
                        status.StatusMsg = " Name Restricted ";
                    }

                    if (status.returnID == -4)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "Restricted word in Name ";
                        status.StatusMsg = " Restricted word in Name ";
                    }
                    if (status.returnID == -3)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "Restricted word in Description ";
                        status.StatusMsg = " Restricted word in Description ";
                    }
                    if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "-2 is the error code for invalid POSTAL code. ";
                        status.StatusMsg = " Invalid POSTAL Code. ";
                    }
                    if (status.returnID >= 100000)
                    {
                        // Whenever a new TELLER is added, a new TOPIC will be created in FCM on the TELLER ID. So that the notification
                        //will be published on the TELLER topic name, it will reach automatically all the subcribers of the TELLER.
                        //Every LISTENER & TELLER should be subscribed to the below TOPIC mandatory according to their POSTCODE
                        //FirebaseMessaging.getInstance().subscribeToTopic("POSTCODE);
                        //FirebaseMessaging.getInstance().subscribeToTopic("POSTCODE);


                        //Whenever a receiver subcribing a TELLER from Services menu that time the below line should be exeucted from the client.
                        //FirebaseMessaging.getInstance().subscribeToTopic("SenderID");

                        //DeviceGroupController dgc = new DeviceGroupController();
                        //Task<string> s=  dgc.CreateTopicGroup(ctblSender.deviceTokenID, status.returnID.ToString());

                        status.StatusID = 0;
                        //status.DesctoDev = s.ToString();


                        status.StatusMsg = " User Successfully Created/Updated ";
                        status.userType  = "S";
                        SendNotificationController s = new SendNotificationController();

                        string        msg;
                        FCMController fcm = new FCMController();
                        cStatus       st  = new cStatus();
                        if (ctblSender.cServiceType != "Personal Use" && ctblSender.cServiceType != "Home Maker")
                        {
                            st = await s.NewTellerNotificationAsync(ctblSender.POSTCODE, ctblSender.SenderName, ctblSender.cServiceType, status.returnID);

                            msg = "@POSTCODE:" + ctblSender.POSTCODE + "@SenderName:" + ctblSender.SenderName + "New user joined @ServiceType:" + ctblSender.cServiceType;

                            if (st.DesctoDev.Contains("message_id"))
                            {
                                status.StatusMsg = "Broadcast success";
                                await fcm.PostFCMResponse(st.DesctoDev, msg, "Y");
                            }
                            else
                            {
                                status.StatusMsg = "Broadcast failed";
                                await fcm.PostFCMResponse(st.DesctoDev, msg, "N");
                            }
                        }
                        ctblEnquiry enq = new ctblEnquiry();
                        string      str;
                        enq.EnquiryID      = 0;
                        str                = @"Welcome to Thandora a Business/Social media app to promote your business and services.

All business users requested to update your Address, Profile picture, business descriptions clearly with commonly searched key words specific to your business.

Any search/enquiry on Thandora related to your business area or business name, would be notified to you through SMS and Thandora notification.

If you are NOT posting for 30 calendar days, your name and services will be made dormant and made unavailable to public. 

You can invite your friends/neighbors/business partners/workers/staffs/contractors/owners to promote their business and services.

WEB: http://www.thandora.co

FB: https://www.facebook.com/search/top/?q=thandora%20-%20a%20business%20app

Regards
Thandora Admin";
                        enq.EnquiryMessage = str;
                        enq.FromUserID     = 100089;
                        enq.FromUserType   = "S";
                        enq.ToUserID       = status.returnID;
                        enq.ToUserType     = "S";
                        enq.AnswerID       = 0;
                        MessageController mc = new MessageController();
                        mc.PostEnquiry(enq);

                        AuthorizationController ac = new AuthorizationController();
                        ac.RefreshUsers();
                    }
                }
            }
            catch (Exception ex)
            {
                retvalue         = ex.Message.ToString();
                status.StatusID  = 1;
                status.StatusMsg = retvalue;
            }

            return(Ok(status));
        }
Пример #10
0
using System;
        public async Task <cStatus> PostMessageNotification(cmsgPostReturn msgPostReturn)
        {
            cStatus           st = new cStatus();
            MessageController mc = new MessageController();
            string            retvalue;

            if (msgPostReturn.broadCast.Equals("Y"))
            {
                ////SEND NOTIFICATION FOR BROADCAST MESSAGECATEGORY

                if (msgPostReturn.msgDistributedTo.Equals("NATIONAL"))
                {
                    st = await PostMsgImageNotificationAsync("INDIA", "INDIA", msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
                }

                if (msgPostReturn.msgDistributedTo.Equals("STATE"))
                {
                    try
                    {
                        List <string> topics;
                        topics = mc.getTopicsforpostcode(msgPostReturn.POSTCODE, "STATE");
                        foreach (string topic in topics)
                        {
                            st = await PostMsgImageNotificationAsync(topic, topic, msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
                        }
                    }
                    catch (Exception ex)
                    {
                        retvalue = ex.Message.ToString();
                    }
                }

                if (msgPostReturn.msgDistributedTo.Equals("DISTRICT"))
                {
                    try
                    {
                        List <string> topics;
                        //postcode = "110006";
                        topics = mc.getTopicsforpostcode(msgPostReturn.POSTCODE, "DISTRICT");
                        foreach (string topic in topics)
                        {
                            st = await PostMsgImageNotificationAsync(topic, topic, msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
                        }
                    }
                    catch (Exception ex)
                    {
                        retvalue = ex.Message.ToString();
                    }
                }

                if (msgPostReturn.msgDistributedTo.Equals("POSTCODE"))
                {
                    st = await PostMsgImageNotificationAsync("LOCAL ", msgPostReturn.POSTCODE, msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
                }

                if (msgPostReturn.msgDistributedTo.Equals("SUBSCRIBER"))
                {
                    st = await PostMsgImageNotificationAsync("SUBSCRIBER", msgPostReturn.senderID.ToString(), msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
                }
            }
            else
            {
                st = await PostMsgImageNotificationAsync("SUBSCRIBER", msgPostReturn.senderID.ToString(), msgPostReturn.sendername, msgPostReturn.msgCategory, msgPostReturn.msgContent, msgPostReturn.msgImagePath, msgPostReturn.retValue, msgPostReturn.senderID);
            }

            return(st);
        }
Пример #12
0
        public async Task <cStatus> Postsubcriberswithnotifiy([FromBody] ctblSubscriber ctblSubscriber)
        {
            cStatus status = new cStatus();

            string retvalue, deviceID, receiverName;

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_addupdate_subscriber", con);
                    cmd.CommandType = CommandType.StoredProcedure;


                    SqlParameter paramReceiverID = new SqlParameter();
                    paramReceiverID.ParameterName = "@ReceiverID";
                    paramReceiverID.Value         = ctblSubscriber.ReceiverID;
                    cmd.Parameters.Add(paramReceiverID);

                    SqlParameter paramReceiverUserType = new SqlParameter();
                    paramReceiverUserType.ParameterName = "@ReceiverUserType";
                    paramReceiverUserType.Value         = ctblSubscriber.ReceiverUserType;
                    cmd.Parameters.Add(paramReceiverUserType);

                    SqlParameter paramSenderID = new SqlParameter();
                    paramSenderID.ParameterName = "@SenderID";
                    cmd.Parameters.Add(paramSenderID);


                    SqlParameter paramsubscribeonoff = new SqlParameter();
                    paramsubscribeonoff.ParameterName = "@subscribeonoff";
                    cmd.Parameters.Add(paramsubscribeonoff);

                    cmd.Parameters.Add("@LastInsertedID", SqlDbType.Int);
                    cmd.Parameters["@LastInsertedID"].Direction = ParameterDirection.Output;

                    cmd.Parameters.Add("@deviceID", SqlDbType.NVarChar, 300);
                    cmd.Parameters["@deviceID"].Direction = ParameterDirection.Output;


                    cmd.Parameters.Add("@receivername", SqlDbType.NVarChar, 50);
                    cmd.Parameters["@receivername"].Direction = ParameterDirection.Output;

                    con.Open();
                    SendNotificationController s = new SendNotificationController();
                    cStatus st = new cStatus();
                    for (int i = 0; i < ctblSubscriber.Senders.Count; i++)
                    {
                        paramSenderID.Value       = ctblSubscriber.Senders[i].SenderID;
                        paramsubscribeonoff.Value = ctblSubscriber.Senders[i].subscribeonoff;
                        cmd.ExecuteNonQuery();
                        deviceID     = cmd.Parameters["@deviceID"].Value.ToString();
                        receiverName = cmd.Parameters["@receivername"].Value.ToString();

                        /* if (ctblSubscriber.Senders[i].subscribeonoff.Contains("ON"))
                         * {
                         * st=await   s.SubscriberNotificationAsync(deviceID, receiverName, " following you @ Thandora");
                         * }
                         * else
                         * {
                         * st=await  s.SubscriberNotificationAsync(deviceID, receiverName, " leaving you @ Thandora");
                         * }
                         * status.DesctoDev = st.DesctoDev;
                         */
                        // status.returnID = int.Parse(retvalue);
                    }
                    con.Close();

                    retvalue        = cmd.Parameters["@LastInsertedID"].Value.ToString();
                    status.returnID = int.Parse(retvalue);
                    if (status.returnID > 0)
                    {
                        status.StatusID  = 0;
                        status.StatusMsg = "Updated successfully";
                        status.DesctoDev = "Updated successfully, Need to call FCM subscribe method";
                    }
                    else if (status.returnID == -1)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Updation failed";
                        status.DesctoDev = "Updation failed, Invalid user ";
                    }
                    else if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Updation failed";
                        status.DesctoDev = "Updation failed, Invalid user ";
                    }

                    // cmd.Dispose();
                }
            }
            catch (Exception ex)
            {
                retvalue         = ex.Message.ToString();
                status.StatusID  = 1;
                status.StatusMsg = retvalue;
                status.DesctoDev = "Updation failed, Please check your internet";
            }

            return(status);

            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }
             *
             * db.ctblSubscribers.Add(ctblSubscriber);
             * db.SaveChanges();
             *
             * return CreatedAtRoute("DefaultApi", new { id = ctblSubscriber.SubscribeID }, ctblSubscriber);*/
        }
Пример #13
0
        public IHttpActionResult PostctblSubscriber([FromBody] ctblSubscriber ctblSubscriber)
        {
            cStatus status = new cStatus();

            string retvalue;

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_addupdate_subscriber", con);
                    cmd.CommandType = CommandType.StoredProcedure;


                    SqlParameter paramReceiverID = new SqlParameter();
                    paramReceiverID.ParameterName = "@ReceiverID";
                    paramReceiverID.Value         = ctblSubscriber.ReceiverID;
                    cmd.Parameters.Add(paramReceiverID);

                    SqlParameter paramReceiverUserType = new SqlParameter();
                    paramReceiverUserType.ParameterName = "@ReceiverUserType";
                    paramReceiverUserType.Value         = ctblSubscriber.ReceiverUserType;
                    cmd.Parameters.Add(paramReceiverUserType);

                    SqlParameter paramSenderID = new SqlParameter();
                    paramSenderID.ParameterName = "@SenderID";
                    cmd.Parameters.Add(paramSenderID);


                    SqlParameter paramsubscribeonoff = new SqlParameter();
                    paramsubscribeonoff.ParameterName = "@subscribeonoff";
                    cmd.Parameters.Add(paramsubscribeonoff);

                    cmd.Parameters.Add("@LastInsertedID", SqlDbType.Int);
                    cmd.Parameters["@LastInsertedID"].Direction = ParameterDirection.Output;

                    con.Open();
                    for (int i = 0; i < ctblSubscriber.Senders.Count; i++)
                    {
                        paramSenderID.Value       = ctblSubscriber.Senders[i].SenderID;
                        paramsubscribeonoff.Value = ctblSubscriber.Senders[i].subscribeonoff;
                        cmd.ExecuteNonQuery();
                    }
                    con.Close();

                    retvalue        = cmd.Parameters["@LastInsertedID"].Value.ToString();
                    status.returnID = int.Parse(retvalue);
                    if (status.returnID > 0)
                    {
                        status.StatusID  = 0;
                        status.StatusMsg = "Subcribed successfully";
                        status.DesctoDev = "Subcribed successfully, Need to call FCM subscribe method";
                    }
                    else if (status.returnID == -1)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Subscription failed";
                        status.DesctoDev = "Subscrited failed, Invalid user ";
                    }
                    else if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Subscription failed";
                        status.DesctoDev = "Subscrited failed, Invalid user ";
                    }

                    // cmd.Dispose();
                }
            }
            catch (Exception ex)
            {
                retvalue         = ex.Message.ToString();
                status.StatusID  = 1;
                status.StatusMsg = retvalue;
                status.DesctoDev = "Subscrited failed, Please check your internet";
            }

            return(Ok(status));

            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }
             *
             * db.ctblSubscribers.Add(ctblSubscriber);
             * db.SaveChanges();
             *
             * return CreatedAtRoute("DefaultApi", new { id = ctblSubscriber.SubscribeID }, ctblSubscriber);*/
        }
Пример #14
0
        public IHttpActionResult PutctblReceiver([FromBody] ctblReceiver ctblReceiver)
        {
            string  retvalue;
            cStatus status = new cStatus();

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_update_receiver", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter paramReceiverID = new SqlParameter();
                    paramReceiverID.ParameterName = "@ReceiverID";
                    paramReceiverID.Value         = ctblReceiver.ReceiverID;
                    cmd.Parameters.Add(paramReceiverID);

                    SqlParameter paramRecName = new SqlParameter();
                    paramRecName.ParameterName = "@ReceiverName";
                    paramRecName.Value         = ctblReceiver.ReceiverName;
                    cmd.Parameters.Add(paramRecName);

                    SqlParameter paramRecPhone = new SqlParameter();
                    paramRecPhone.ParameterName = "@ReceiverPhone";
                    paramRecPhone.Value         = ctblReceiver.ReceiverPhone;
                    cmd.Parameters.Add(paramRecPhone);

                    SqlParameter paramAddress = new SqlParameter();
                    paramAddress.ParameterName = "@Address";
                    paramAddress.Value         = ctblReceiver.Address;
                    cmd.Parameters.Add(paramAddress);


                    SqlParameter paramPOSTCODE = new SqlParameter();
                    paramPOSTCODE.ParameterName = "@POSTCODE";
                    paramPOSTCODE.Value         = ctblReceiver.POSTCODE;
                    cmd.Parameters.Add(paramPOSTCODE);

                    SqlParameter paramActiveUser = new SqlParameter();
                    paramActiveUser.ParameterName = "@ActiveUser";
                    paramActiveUser.Value         = ctblReceiver.ActiveUser;
                    cmd.Parameters.Add(paramActiveUser);

                    cmd.Parameters.Add("@LastupdatedID", SqlDbType.Int);
                    cmd.Parameters["@LastupdatedID"].Direction = ParameterDirection.Output;


                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    retvalue        = cmd.Parameters["@LastupdatedID"].Value.ToString();
                    status.returnID = int.Parse(retvalue);
                    if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "-2 is the error code for invalid POSTAL code. ";
                        status.StatusMsg = " Invalid POSTAL Code. ";
                    }
                    if (status.returnID >= 100000)
                    {
                        status.StatusID  = 0;
                        status.DesctoDev = "Store the returnID in Users Mobile database with UserType = R";
                        status.StatusMsg = " Listener Successfully Created/Updated ";
                    }
                }
            }
            catch (Exception ex)
            {
                retvalue = ex.Message.ToString();
            }


            return(Ok(status));
        }
Пример #15
0
        public async Task <cguestModeStatus> PostctblSender([FromBody] cGuestMode cgmode)
        {
            cStatus          status       = new cStatus();
            cguestModeStatus cguesttopics = new cguestModeStatus();
            string           retvalue;

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_guest_OnOff", con);
                    cmd.CommandType = CommandType.StoredProcedure;


                    SqlParameter paramuserID = new SqlParameter();
                    paramuserID.ParameterName = "@userID";
                    paramuserID.Value         = cgmode.userID;
                    cmd.Parameters.Add(paramuserID);

                    SqlParameter paramuserType = new SqlParameter();
                    paramuserType.ParameterName = "@userType";
                    paramuserType.Value         = cgmode.userType;
                    cmd.Parameters.Add(paramuserType);

                    SqlParameter paramgPOSTCODE = new SqlParameter();
                    paramgPOSTCODE.ParameterName = "@guest_postcode";
                    paramgPOSTCODE.Value         = cgmode.gPOSTCODE;
                    cmd.Parameters.Add(paramgPOSTCODE);


                    SqlParameter paramis_guest_mode = new SqlParameter();
                    paramis_guest_mode.ParameterName = "@is_guest_mode";
                    paramis_guest_mode.Value         = cgmode.is_guest_mode;
                    cmd.Parameters.Add(paramis_guest_mode);


                    cmd.Parameters.Add("@result", SqlDbType.Int);
                    cmd.Parameters["@result"].Direction = ParameterDirection.Output;


                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();


                    retvalue         = cmd.Parameters["@result"].Value.ToString();
                    status.DesctoDev = cmd.Parameters["@guest_postcode"].Value.ToString();
                    status.returnID  = int.Parse(retvalue);
                    if (status.returnID == 0)
                    {
                        status.StatusID = 0;
                        //status.DesctoDev = "Execute FCM subscribe method for the new POSTCODE ";
                        status.StatusMsg = " GUEST MODE ON ";
                    }
                    if (status.returnID == 1)
                    {
                        status.StatusID = 0;
                        //status.DesctoDev = "Execute FCM UNsubscribe method for the guest POSTCODE ";
                        status.StatusMsg = " GUEST MODE OFF ";
                    }

                    if (status.returnID == -1)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "NOT ACTIVE USER ";
                        status.StatusMsg = " NOT ACTIVE USER";
                    }
                    if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = " POST CODE NOT AVAILABLE ";
                        status.StatusMsg = " GUEST POSTCODE NOT AVAILABLE";
                    }
                    if (status.returnID == -3)
                    {
                        status.StatusID  = 1;
                        status.DesctoDev = "SAME POST CODE ";
                        status.StatusMsg = "GUEST POSTCODE SHOULD BE DIFFERENT FROM YOUR ORIGINAL POSTCODE ";
                    }

                    if (status.StatusID == 0)
                    {
                        AuthorizationController ca = new AuthorizationController();
                        cguesttopics.AreaNames = await ca.GetGuestModeTopics(cgmode.userID, cgmode.userType, status.DesctoDev);

                        cguesttopics.status = status;
                    }
                    else
                    {
                        cguesttopics.AreaNames = new List <string>();
                        cguesttopics.status    = status;
                    }
                }
            }
            catch (Exception ex)
            {
                status.StatusMsg       = ex.Message.ToString();
                status.StatusID        = 1;
                cguesttopics.status    = status;
                cguesttopics.AreaNames = new List <string>();
            }

            return(cguesttopics);
        }
        public async Task <cStatus> EnquiryNotificationAsync(string DeviceID, string FromUser, string Message, int id, string NotifyType, int senderID)
        {
            cStatus       st         = new cStatus();
            FCMController fcm        = new FCMController();
            ctblFCM       fcmDetails = new ctblFCM();

            fcmDetails = (ctblFCM)fcm.GetctblFCM(1);

            string uri;

            uri = "https://fcm.googleapis.com/fcm/send";

            try
            {
                var client  = new RestClient(uri);
                var request = new RestRequest(Method.POST);

                request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY));
                request.AddHeader("content-type", "application/json");
                request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY));

                /*var postData = new
                 * {
                 *  to = DeviceID,
                 *  data = new
                 *  {
                 *      MessageID = enquiryid
                 *  },
                 *
                 *  notification = new
                 *  {
                 *      body = enquirymessage,
                 *      title = FromUser,
                 *      icon = "myicon"
                 *  }
                 * };*/
                int typeid = 0;
                if (NotifyType == "Comments")
                {
                    typeid = 2;
                }
                if (NotifyType == "Enquiry")
                {
                    typeid = 3;
                }

                if (NotifyType == "Feedback")
                {
                    typeid = 4;
                }

                var postData = new
                {
                    to   = DeviceID,
                    data = new
                    {
                        title            = NotifyType,
                        message          = Message,
                        SenderName       = FromUser,
                        imageUrl         = "",
                        messageId        = id,
                        SenderID         = senderID,
                        notificationType = typeid  //(1->PostMessage, 2-- > Comment, 3 --> Enquiry, and so on)
                    },
                    priority = "high"
                };

                var serializer = new JavaScriptSerializer();
                var json       = serializer.Serialize(postData);

                //request.AddParameter("application/json", "{\r\n                \"to\" : \""+DeviceID+"\"\r\n                \"data\":{\r\n                \t \"enquiryID\": "+enquiryid.ToString()+"\r\n                }\r\n                \r\n                \"notification\":\r\n                {\r\n                    \"body\": \""+enquirymessage+"\",\r\n                    \"title\":\""+FromUser +"\",\r\n                    \"icon\": \"myicon\"\r\n                }\r\n            }", ParameterType.RequestBody);

                //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new
                // { body = enquirymessage, title = FromUser,icon = "myicon"  } }) , ParameterType.RequestBody);

                request.AddParameter("application/json", json, ParameterType.RequestBody);

                /*var rs = client.Execute(request);
                 * sResponseFromServer = rs.Content.ToString();
                 * return sResponseFromServer;*/
                //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete);

                IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request);

                //return asyncHandle.Content.ToString();
                st.DesctoDev = asyncHandle.Content.ToString();
                st.returnID  = asyncHandle.Data.success;
                st.StatusID  = asyncHandle.Data.failure;
                //return asyncHandle.Data.success.ToString();
                return(st);
            }
            catch (Exception ex)
            {
                st.StatusID  = 1;//  Notification failure
                st.StatusMsg = ex.Message.ToString();
                return(st);
            }
        }
        public async Task <cStatus> SubscriberNotificationAsync(string DeviceID, string subscriber, string msg)
        {
            cStatus       st         = new cStatus();
            FCMController fcm        = new FCMController();
            ctblFCM       fcmDetails = new ctblFCM();

            fcmDetails = (ctblFCM)fcm.GetctblFCM(1);

            string uri;

            uri = "https://fcm.googleapis.com/fcm/send";

            try
            {
                var client  = new RestClient(uri);
                var request = new RestRequest(Method.POST);

                request.AddHeader("sender", string.Format("id={0}", fcmDetails.PROJECT_KEY));
                request.AddHeader("content-type", "application/json");
                request.AddHeader("authorization", string.Format("key={0}", fcmDetails.SERVER_API_KEY));
                var postData = new
                {
                    to   = DeviceID,
                    data = new
                    {
                        MessageID = 1
                    },
                    priority     = "high",
                    notification = new
                    {
                        body  = subscriber + msg,
                        title = "Subscription update",
                        icon  = "myicon"
                    }
                };

                var serializer = new JavaScriptSerializer();
                var json       = serializer.Serialize(postData);

                //request.AddParameter("application/json", "{\r\n                \"to\" : \""+DeviceID+"\"\r\n                \"data\":{\r\n                \t \"enquiryID\": "+enquiryid.ToString()+"\r\n                }\r\n                \r\n                \"notification\":\r\n                {\r\n                    \"body\": \""+enquirymessage+"\",\r\n                    \"title\":\""+FromUser +"\",\r\n                    \"icon\": \"myicon\"\r\n                }\r\n            }", ParameterType.RequestBody);

                //request.AddParameter("application/json", request.JsonSerializer.Serialize( new {to = DeviceID, data = new {MessageID = enquiryid}, notification = new
                // { body = enquirymessage, title = FromUser,icon = "myicon"  } }) , ParameterType.RequestBody);

                request.AddParameter("application/json", json, ParameterType.RequestBody);

                /*var rs = client.Execute(request);
                 * sResponseFromServer = rs.Content.ToString();
                 * return sResponseFromServer;*/
                //var asyncHandle = await client.ExecuteAsync(request, NotificationOnComplete);

                IRestResponse <cFCMReturn> asyncHandle = await client.ExecutePostTaskAsync <cFCMReturn>(request);

                //return asyncHandle.Content.ToString();
                st.DesctoDev = asyncHandle.Content.ToString();
                st.returnID  = asyncHandle.Data.success;
                st.StatusID  = asyncHandle.Data.failure;
                //return asyncHandle.Data.success.ToString();
                return(st);
            }
            catch (Exception ex)
            {
                st.StatusID  = 1;//  Notification failure
                st.StatusMsg = ex.Message.ToString();
                return(st);
            }
        }
Пример #18
0
        private void tsbtnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                cStatus cs = new cStatus();

                #region VALIDAÇÃO
                if (string.IsNullOrEmpty(txtStatus.Text))
                {
                    tsslblMsg.Text = "Nome do status não informado";
                    txtStatus.Focus();
                    return;
                }
                #endregion

                if (!cGlobal.editando)
                {
                    cs.status = txtStatus.Text.ToUpper();
                    cs.grava_status(cs);
                    MessageBox.Show("Status registrado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    #region LOG
                    cLog lg = new cLog();
                    lg.log = string.Concat("Cadastro de Registro.", Environment.NewLine,
                                           "Status: ", txtStatus.Text.ToUpper()
                                           );
                    lg.form        = this.Text;
                    lg.metodo      = sender.ToString();
                    lg.dt          = DateTime.Now;
                    lg.usersistema = cGlobal.userlogado;
                    lg.userRede    = Environment.UserName;
                    lg.terminal    = Environment.MachineName;
                    lg.tp_flag     = true;
                    lg.grava_log(lg);
                    #endregion
                }
                else
                {
                    cs.id_status = Convert.ToInt32(txtID.Text);
                    cs.status    = txtStatus.Text.ToUpper();
                    cs.atualiza_cadastro_status(cs);
                    MessageBox.Show("O Status foi alterado com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    #region LOG
                    cLog lg = new cLog();
                    lg.log = string.Concat("Alteração de Registro.", Environment.NewLine,
                                           "Status: ", txtStatus.Text.ToUpper()
                                           );
                    lg.form        = this.Text;
                    lg.metodo      = sender.ToString();
                    lg.dt          = DateTime.Now;
                    lg.usersistema = cGlobal.userlogado;
                    lg.userRede    = Environment.UserName;
                    lg.terminal    = Environment.MachineName;
                    lg.tp_flag     = true;
                    lg.grava_log(lg);
                    #endregion
                }

                inicio();
            }
            catch (Exception ex)
            {
                #region LOG ERRO
                cLog lg = new cLog();
                lg.log         = ex.Message.Replace("'", "");
                lg.form        = this.Text;
                lg.metodo      = sender.ToString();
                lg.dt          = DateTime.Now;
                lg.usersistema = cGlobal.userlogado;
                lg.userRede    = Environment.UserName;
                lg.terminal    = Environment.MachineName;
                lg.tp_flag     = false;
                lg.grava_log(lg);
                #endregion
            }
        }
        public async Task <HttpResponseMessage> PostUserProfileImage(int SenderID)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();
            cStatus status   = new cStatus();
            var     logopath = "";

            try
            {
                var httpRequest = HttpContext.Current.Request;

                foreach (string file in httpRequest.Files)
                {
                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);

                    var postedFile = httpRequest.Files[file];
                    if (postedFile != null && postedFile.ContentLength > 0)
                    {
                        int MaxContentLength = 1024 * 1024 * 1; //Size = 1 MB

                        IList <string> AllowedFileExtensions = new List <string> {
                            ".jpg", ".gif", ".png"
                        };
                        var ext       = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));
                        var extension = ext.ToLower();
                        if (!AllowedFileExtensions.Contains(extension))
                        {
                            // var message = string.Format("Please Upload image of type .jpg,.gif,.png.");
                            status.StatusMsg = "Please Upload image of type .jpg,.gif,.png.";
                            status.StatusID  = 1;


                            //dict.Add("error", message);
                            //return Request.CreateResponse(HttpStatusCode.BadRequest, status);
                        }
                        else if (postedFile.ContentLength > MaxContentLength)
                        {
                            // var message = string.Format("Please Upload a file upto 1 mb.");
                            status.StatusMsg = "Image below 1 MB preferable.";
                            status.StatusID  = 1;

                            //dict.Add("error", message);
                            //return Request.CreateResponse(HttpStatusCode.BadRequest, status);
                        }
                        else
                        {
                            var filePath = HttpContext.Current.Server.MapPath("~/Userimage/" + SenderID.ToString() + extension);

                            logopath = "http://joinwithme.in/thandoraAPI/userimage/" + SenderID.ToString() + extension;
                            postedFile.SaveAs(filePath);
                        }
                    }

                    // var message1 = string.Format("Image Updated Successfully.");
                    status.StatusMsg = "Image Updated Successfully.";
                    status.StatusID  = 0;

                    string retvalue;
                    try
                    {
                        string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                        using (SqlConnection con = new SqlConnection(constr))
                        {
                            SqlCommand cmd = new SqlCommand("sp_update_sender_image", con);
                            cmd.CommandType = CommandType.StoredProcedure;

                            SqlParameter paramSenderID = new SqlParameter();
                            paramSenderID.ParameterName = "@SenderID";
                            paramSenderID.Value         = SenderID;
                            cmd.Parameters.Add(paramSenderID);

                            SqlParameter paramlogopath = new SqlParameter();
                            paramlogopath.ParameterName = "@logopath";
                            paramlogopath.Value         = logopath;
                            cmd.Parameters.Add(paramlogopath);

                            cmd.Parameters.Add("@LastupdatedID", SqlDbType.Int);
                            cmd.Parameters["@LastupdatedID"].Direction = ParameterDirection.Output;


                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                            retvalue = cmd.Parameters["@LastupdatedID"].Value.ToString();
                            if (int.Parse(retvalue) > 0)
                            {
                                status.StatusMsg = "Image Updated Successfully.";
                                status.StatusID  = 0;
                                status.DesctoDev = logopath;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        retvalue         = ex.Message.ToString();
                        status.StatusID  = 1;
                        status.StatusMsg = "Image upload failed";
                    }
                    //return Request.CreateResponse(HttpStatusCode.Created, status.StatusMsg);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, status));
            }
            catch (Exception ex)
            {
                status.StatusID  = 1;
                status.StatusMsg = ex.Message.ToString();

                return(Request.CreateResponse(HttpStatusCode.NotFound, status));
            }
        }
Пример #20
0
        private void inicio()
        {
            try
            {
                txtID.Text     = string.Empty;
                txtStatus.Text = string.Empty;
                txtStatus.Focus();

                cStatus cs = new cStatus();
                using (DataSet ds = cs.preenche_lista_status())
                {
                    using (DataTable dt = ds.Tables["Status"])
                    {
                        #region listview
                        lvStatus.Clear();
                        lvStatus.View               = View.Details;
                        lvStatus.LabelEdit          = true;
                        lvStatus.AllowColumnReorder = true;
                        lvStatus.CheckBoxes         = false;
                        lvStatus.FullRowSelect      = true;
                        lvStatus.GridLines          = true;
                        //lvStatus.Sorting = SortOrder.Ascending;

                        lvStatus.Columns.Add("ID", 50);
                        lvStatus.Columns.Add("Status", 430, HorizontalAlignment.Left);
                        //lvStatus.Columns.Add("Cadastro por", 120, HorizontalAlignment.Left);
                        //lvStatus.Columns.Add("Data Cadastro", 120, HorizontalAlignment.Left);

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            DataRow      drw = dt.Rows[i];
                            ListViewItem lvi = new ListViewItem(drw["ID_STATUS"].ToString());
                            lvi.SubItems.Add(drw["STATUS"].ToString());
                            //lvi.SubItems.Add(drw["USERCAD"].ToString());
                            //lvi.SubItems.Add(drw["DTCAD"].ToString());
                            lvStatus.Items.Add(lvi);
                        }

                        lblTotalReg.Text = string.Concat("Total de ", lvStatus.Items.Count, " registro(s)");
                        #endregion
                    }
                }

                if (lvStatus.Items.Count == 0)
                {
                    mnuOculto.Enabled = false;
                }
                else
                {
                    mnuOculto.Enabled = true;
                }

                if (lvStatus.Items.Count > 0)
                {
                    lvStatus.Items[0].Selected = true;
                    lvStatus_Click(null, null);
                }
            }
            catch (Exception ex)
            {
                #region LOG ERRO
                cLog lg = new cLog();
                lg.log         = ex.Message.Replace("'", "");
                lg.form        = this.Text;
                lg.metodo      = "Inicio";
                lg.dt          = DateTime.Now;
                lg.usersistema = cGlobal.userlogado;
                lg.userRede    = Environment.UserName;
                lg.terminal    = Environment.MachineName;
                lg.tp_flag     = false;
                lg.grava_log(lg);
                #endregion
            }
        }
Пример #21
0
        static void Main(string[] args)
        {
            bool online = true;

            //Client initalisieren
            Portal           system = new Portal(100);
            PortalCollection PC     = new PortalCollection();

            PC.RegisterPortal(system);
            system.IncomingPacket += OnSystemPacket;

            TestRequest myRequest = new TestRequest();

            PC.RegisterRequest(myRequest, system, 501);

            TestChannel myChannel = new TestChannel();

            PC.RegisterChannel(myChannel, system, 502);


            // ###########################################################
            // Create a TestCert in CMD: makecert -sr LocalMachine -ss root -r -n "CN=localhost" -sky exchange -sk 123456
            // Do not use in Production | do not use localhost -> use your machinename!
            // ###########################################################


            /*//Import Test Cert from local store
             * X509Certificate2Collection cCollection = new X509Certificate2Collection();
             *
             * X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
             * store.Open(OpenFlags.ReadOnly);
             * var certificates = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, "CN=localhost", false);
             * store.Close();
             *
             * if (certificates.Count == 0)
             * {
             *  Console.WriteLine("Server certificate not found...");
             *  Console.ReadKey();
             *  return;
             * }
             * else
             * {
             *  cCollection.Add(certificates[0]);
             * }
             * // Get the value.
             * string resultsTrue = cCollection[0].ToString(true);
             * // Display the value to the console.
             * Console.WriteLine(resultsTrue);
             * // Get the value.
             * string resultsFalse = cCollection[0].ToString(false);
             * // Display the value to the console.
             * Console.WriteLine(resultsFalse);*/



            /*System.Timers.Timer _aTimer = new System.Timers.Timer(1);
             * _aTimer.Elapsed += DoPackets;
             * _aTimer.AutoReset = true;
             * _aTimer.Enabled = true;*/
            Thread.Sleep(100);

            VaserSSLClient      ssl      = new VaserSSLClient("localhost");
            VaserKerberosClient kerberos = new VaserKerberosClient();
            Link lnk1 = VaserClient.ConnectClient("localhost", 3100, PC);

            lnk1.EmptyBuffer += OnEmptyBuffer;

            if (lnk1 != null)
            {
                Console.WriteLine("1: successfully established connection.");
            }

            //working
            if (lnk1.IsConnected)
            {
                Console.WriteLine("Test. Con OK");
            }

            cStatus sts = myRequest.myRequestStarter("HELLO WORLD!", lnk1);

            myChannel.mySendStarter("This is my channel tester", lnk1);

            while (online)
            {
                if (sts != null)
                {
                    if (sts.Done && !sts.Error)
                    {
                        Console.WriteLine("Request Done Result: " + (string)sts.ResultObject);
                        sts    = null;
                        online = false;
                    }
                    if (sts != null && sts.Error)
                    {
                        Console.WriteLine("Error: " + sts.Message);
                        sts    = null;
                        online = false;
                    }
                }
                Thread.Sleep(1000);

                //entfernen
                //if (lnk1.IsConnected == false) online = false;
            }
            //Client1.CloseClient();
            lnk1.Dispose();

            Console.WriteLine("Test ended... press any key...");
            Console.ReadKey();
        }
Пример #22
0
        public async Task <cStatus> TellerUpdate([FromBody] ctblSender ctblSender)
        {
            cStatus status = new cStatus();

            try
            {
                string constr = ConfigurationManager.ConnectionStrings["MyAbDbContext"].ConnectionString;

                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand cmd = new SqlCommand("sp_update_sender", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter paramSenderID = new SqlParameter();
                    paramSenderID.ParameterName = "@SenderID";
                    paramSenderID.Value         = ctblSender.SenderID;
                    cmd.Parameters.Add(paramSenderID);

                    SqlParameter paramSendName = new SqlParameter();
                    paramSendName.ParameterName = "@SenderName";
                    paramSendName.Value         = ctblSender.SenderName;
                    cmd.Parameters.Add(paramSendName);


                    SqlParameter paramSenderContactNo_1 = new SqlParameter();
                    paramSenderContactNo_1.ParameterName = "@SenderContactNo_1";
                    paramSenderContactNo_1.Value         = ctblSender.SenderContactNo_1;
                    cmd.Parameters.Add(paramSenderContactNo_1);


                    SqlParameter paramContactHide = new SqlParameter();
                    paramContactHide.ParameterName = "@ContactHide";
                    paramContactHide.Value         = ctblSender.ContactHide;
                    cmd.Parameters.Add(paramContactHide);

                    SqlParameter paramcServiceType = new SqlParameter();
                    paramcServiceType.ParameterName = "@cServiceType";
                    paramcServiceType.Value         = ctblSender.cServiceType;
                    cmd.Parameters.Add(paramcServiceType);

                    SqlParameter paramServiceDesc = new SqlParameter();
                    paramServiceDesc.ParameterName = "@ServiceDesc";
                    paramServiceDesc.Value         = ctblSender.ServiceDesc;
                    cmd.Parameters.Add(paramServiceDesc);



                    SqlParameter paramAddress = new SqlParameter();
                    paramAddress.ParameterName = "@Address";
                    paramAddress.Value         = ctblSender.Address;
                    cmd.Parameters.Add(paramAddress);

                    cmd.Parameters.Add("@LastUpdatedID", SqlDbType.Int);
                    cmd.Parameters["@LastUpdatedID"].Direction = ParameterDirection.Output;

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    status.returnID = (int)cmd.Parameters["@LastUpdatedID"].Value;
                    if (status.returnID == -2)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "You are not active user";
                    }
                    if (status.returnID == -3)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Bad word in Service description";
                    }
                    if (status.returnID == -4)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Bad word in  Name ";
                    }
                    if (status.returnID == -5)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Name Not Allowed ";
                    }

                    if (status.returnID == -6)
                    {
                        status.StatusID  = 1;
                        status.StatusMsg = "Name Not Available ";
                    }

                    if (status.returnID > 1)
                    {
                        status.StatusID  = 0;
                        status.StatusMsg = "Profile updated successfully ";
                    }
                }
            }
            catch (Exception ex)
            {
                status.StatusMsg = ex.Message.ToString();
            }
            return(status);
        }