コード例 #1
0
        public bool InsertFurnaceSwitchAPI(ENT.FurnaceSwitchParam objENT)
        {
            bool row = false;

            try
            {
                sqlCMD             = new SqlCommand();
                sqlCMD.CommandText = "InsertUpdateDeleteFurnaceSwitchAPI";
                sqlCMD.Parameters.AddWithValue("@fur_id", objENT.fur_id);
                sqlCMD.Parameters.AddWithValue("@fur_name", objENT.fur_name);
                sqlCMD.Parameters.AddWithValue("@fur_no", objENT.fur_no);
                sqlCMD.Parameters.AddWithValue("@fur_status", objENT.fur_status);
                sqlCMD.Parameters.AddWithValue("@fur_open_time", objENT.fur_open_time);
                sqlCMD.Parameters.AddWithValue("@fur_close_time", objENT.fur_close_time);
                sqlCMD.Parameters.AddWithValue("@fur_entry_time", objENT.fur_entry_time);
                sqlCMD.Parameters.AddWithValue("@fur_file_time", objENT.fur_file_time);
                row = objCRUD.InsertUpdateDelete(sqlCMD);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(row);
        }
コード例 #2
0
        public HttpResponseMessage InsertFurnaceSwitchAPI(ENT.FurnaceSwitchParam obj)
        {
            bool IsSuccess = false, IsSendToFcm = false; string ResMessage = string.Empty;

            try
            {
                if (obj != null)
                {
                    // insert data into live database
                    if (new DAL.FurnaceSwitch().InsertFurnaceSwitchAPI(obj))
                    {
                        ResMessage = "Data save successfully.";

                        #region Send Heat Data To FCM
                        if (!string.IsNullOrWhiteSpace(obj.fur_json))
                        {
                            FCMRootObject FCMData          = new FCMRootObject();
                            Notification  NotificationBody = new Notification();
                            Data          NotificationData = new Data();

                            // Send notification if device token found.
                            int count = 0;
                            List <ENT.Device> lstENT = getDeviceID();
                            for (int i = 0; i < lstENT.Count; i++)
                            {
                                if (!string.IsNullOrWhiteSpace(lstENT[i].DeviceId))
                                {
                                    FCMData.to = lstENT[i].DeviceId;
                                    NotificationData.Description = obj.fur_json;
                                    NotificationBody.title       = "GI ADMIN";
                                    NotificationBody.body        = obj.fur_json;
                                    FCMData.data = NotificationData;
                                    // FCMData.notification = NotificationBody;

                                    // send notification using FCM sender
                                    FCMResponse s = new FCMSender().SendClientNotification(FCMData);
                                    if (s.success > 0)
                                    {
                                        // successfull send notification count
                                        count++;
                                    }
                                }
                            }
                            if (count == lstENT.Count)
                            {
                                IsSendToFcm = true;
                            }
                            else
                            {
                                IsSendToFcm = false;
                            }
                            ResMessage += " And [" + count.ToString() + "] Notification Send Successfull Out of [" + lstENT.Count + "].";
                        }
                        #endregion

                        return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { response = ResMessage }));
                    }
                    else
                    {
                        return(ControllerContext.Request.CreateResponse(HttpStatusCode.InternalServerError, new { response = "Internal Server Error." }));
                    }
                }
                else
                {
                    return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { response = "Data should not be empty or null." }));
                }
            }
            catch (Exception ex)
            {
                ERRORREPORTING.Report(ex, Request.RequestUri.AbsoluteUri, new Guid("00000000-0000-0000-0000-000000000000"), "Gujarat_Intrux", "Function Name : SaveDeviceID()");
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.InternalServerError, new { ex.Message }));
            }
        }