コード例 #1
0
        /// <summary>
        ///  Insert Notification Log
        /// </summary>
        /// <param name="oNotificationLogViewModel"></param>
        /// <returns></returns>
        public Response oInsertNotificationLog(NotificationLogViewModel oNotificationLogViewModel)
        {
            #region ": Insert Sp Result:"

            Response oResponse = new Response();

            try
            {
                List <DbParameter> arrParameters = new List <DbParameter>();

                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_ApplicationID", SqlDbType.Int, oNotificationLogViewModel.APPLICATION_ID, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_NotificationType", SqlDbType.VarChar, oNotificationLogViewModel.NOTIFICATION_TYPE, 50, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_RequestJSON", SqlDbType.NVarChar, oNotificationLogViewModel.REQUEST_JSON, 4000, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_ResponseMessage", SqlDbType.VarChar, oNotificationLogViewModel.RESPONSE_MESSAGE, 5000, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_MobileNumbers", SqlDbType.VarChar, oNotificationLogViewModel.MOBILE_NUMBERS, 5000, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pin_IsSentNotification", SqlDbType.Bit, oNotificationLogViewModel.IS_SENT_NOTIFICATION, ParameterDirection.Input));
                arrParameters.Add(CustomDbParameter.BuildParameter("Pout_Error", SqlDbType.Int, ParameterDirection.Output));

                this.ExecuteStoredProcedureCommand("InsertNotificationLog", arrParameters.ToArray());
                oResponse.OperationResult = (enumOperationResult)Enum.Parse(typeof(enumOperationResult), arrParameters[5].Value.ToString());
            }
            catch (Exception Ex)
            {
                oResponse.OperationResult = enumOperationResult.Faild;
                //TODO : Log Error Message
                oResponse.OperationResultMessage = Ex.Message.ToString();
            }

            return(oResponse);

            #endregion
        }
コード例 #2
0
        public void SendTicketChatPushNotification(int nTicketID, string sContent, bool bIsFileTypeChat, TicketChatViewModel oTicketChatViewModel)
        {
            List <TicketMobileUserParticipantViewModel> lstTicketMobileUserParticipantViewModel = this.oITicketServices.IlGetTicketMobileUserParticipants(nTicketID, -99);

            if (lstTicketMobileUserParticipantViewModel.Count > 0)
            {
                foreach (var oTicketMobileUserParticipantViewModel in lstTicketMobileUserParticipantViewModel)
                {
                    if (!oTicketMobileUserParticipantViewModel.DEVICE_ID.Equals(string.Empty))
                    {
                        PushNotification oPushNotification = new PushNotification();
                        oPushNotification.NotificationType = enmNotificationType.TicketChats;
                        oPushNotification.sHeadings        = oTicketMobileUserParticipantViewModel.TICKET_NAME;
                        if (bIsFileTypeChat)
                        {
                            oPushNotification.sContent = string.Format("{0} {1}", CurrentUser.sUserFullNameEnglish, oTicketMobileUserParticipantViewModel.PreferedLanguage == Data.Core.Languages.English ? " has uploaded a file" : "تحميل ملف.");
                        }
                        else
                        {
                            oPushNotification.sContent = string.Format("{0} : {1}", CurrentUser.sUserFullNameEnglish, sContent);
                        }


                        oPushNotification.enmLanguage          = oTicketMobileUserParticipantViewModel.PreferedLanguage;
                        oPushNotification.sDeviceID            = oTicketMobileUserParticipantViewModel.DEVICE_ID;
                        oPushNotification.oTicketChatViewModel = oTicketChatViewModel;
                        oPushNotification.sOneSignalAppID      = this.CurrentApplicationOneSignalID;
                        oPushNotification.sOneSignalAuthKey    = this.CurrentApplicationOneSignalAuthKey;
                        oPushNotification.SendPushNotification();
                        NotificationLogViewModel oNotificationLogViewModel = new NotificationLogViewModel();
                        oNotificationLogViewModel.APPLICATION_ID       = this.CurrentApplicationID;
                        oNotificationLogViewModel.NOTIFICATION_TYPE    = "tickets";
                        oNotificationLogViewModel.REQUEST_JSON         = oPushNotification.sRequestJSON;
                        oNotificationLogViewModel.RESPONSE_MESSAGE     = oPushNotification.sResponseResult;
                        oNotificationLogViewModel.MOBILE_NUMBERS       = oTicketMobileUserParticipantViewModel.PHONE_NUMBER;
                        oNotificationLogViewModel.IS_SENT_NOTIFICATION = oPushNotification.bIsSentNotification;
                        oICommonServices.oInsertNotificationLog(oNotificationLogViewModel);
                    }
                }
            }



            //if (oTicketChatViewModel.TICKET_CHAT_TYPE_ID != 1)
            //{
            //    oPushNotification.sContent = "File uploaded";
            //}
            //else
            //{
            //    oPushNotification.sContent = oTicketChatViewModel.REPLY_MESSAGE.Length > 25 ? oTicketChatViewModel.REPLY_MESSAGE.Substring(0, 100) + "..." : oTicketChatViewModel.REPLY_MESSAGE;
            //}
        }
コード例 #3
0
        public JsonResult JSaveEvent(EventViewModel oEventViewModel)
        {
            oEventViewModel.EVENT_DESCRIPTION = oEventViewModel.EVENT_DESCRIPTION.Replace(Environment.NewLine, "</br>");
            Response           oResponseResult   = null;
            string             sRealFileName     = string.Empty;
            string             sModifiedFileName = string.Empty;
            HttpPostedFileBase filebase          = null;
            var oFile = System.Web.HttpContext.Current.Request.Files["EventImage"];

            if (oFile != null)
            {
                filebase = new HttpPostedFileWrapper(oFile);
                if (filebase.ContentLength > 0)
                {
                    sRealFileName     = filebase.FileName;
                    sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                    oEventViewModel.EVENT_IMG_FILE_PATH = Path.Combine(this.CurrentApplicationID.ToString(), "Events", sModifiedFileName).Replace('\\', '/');
                }
            }
            oEventViewModel.EVENT_DATE     = DateTime.ParseExact(string.Format("{0} {1}", oEventViewModel.FORMATTED_EVENT_DATE, oEventViewModel.EVENT_TIME), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
            oEventViewModel.CREATED_BY     = Convert.ToInt32(CurrentUser.nUserID);
            oEventViewModel.APPLICATION_ID = CurrentApplicationID;
            oEventViewModel.LANGUAGE_ID    = Convert.ToInt32(this.CurrentApplicationLanguage);

            oResponseResult      = this.oIEventService.oInsertEvent(oEventViewModel);
            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:

                if (oFile != null)
                {
                    FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                    try
                    {
                        //DirectoryPath = Saved Application ID + Evemts Folder
                        string sDirectoryPath = Path.Combine(this.CurrentApplicationID.ToString(), "Events");
                        string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                        oFileAccessService.CreateDirectory(sDirectoryPath);

                        MagickImage oMagickImage = new MagickImage(filebase.InputStream);
                        oMagickImage.Format = MagickFormat.Png;
                        oMagickImage.Resize(Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageWidth)), Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageHeight)));

                        oFileAccessService.WirteFileByte(sFullFilePath, oMagickImage.ToByteArray());
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(ex));
                    }
                }

                if (oEventViewModel.IS_NOTIFY_USER && oEventViewModel.IS_ACTIVE)
                {
                    string sEventName = oEventViewModel.EVENT_NAME;
                    string sEventDesc = oEventViewModel.EVENT_DESCRIPTION.Substring(0, Math.Min(oEventViewModel.EVENT_DESCRIPTION.Length, 150)) + "...";

                    #region Send Push Notification

                    var lstApplicationUsers = this.oIUserServices.lGetApplicationUsers(this.CurrentApplicationID, Convert.ToInt32(enumUserType.MobileUser).ToString());
                    if (lstApplicationUsers.Count > 0)
                    {
                        string sDeviceIDS = string.Join(",", lstApplicationUsers.Where(o => Convert.ToInt32(o.PREFERED_LANGUAGE_ID) == (int)this.CurrentApplicationLanguage)
                                                        .Where(o => o.DEVICE_ID != null)
                                                        .Where(o => o.DEVICE_ID != string.Empty)
                                                        .Where(o => o.IS_ACTIVE == true)
                                                        .Where(o => o.IS_BLOCKED == false)
                                                        .Select(o => o.DEVICE_ID.ToString()));

                        string sMobileNumbers = string.Join(",", lstApplicationUsers.Where(o => Convert.ToInt32(o.PREFERED_LANGUAGE_ID) == (int)this.CurrentApplicationLanguage)
                                                            .Where(o => o.DEVICE_ID != null)
                                                            .Where(o => o.DEVICE_ID != string.Empty)
                                                            .Where(o => o.IS_ACTIVE == true)
                                                            .Where(o => o.IS_BLOCKED == false)
                                                            .Select(o => o.PHONE_NUMBER.ToString()));


                        PushNotification oPushNotification = new PushNotification();
                        oPushNotification.NotificationType  = enmNotificationType.Events;
                        oPushNotification.sHeadings         = sEventName;
                        oPushNotification.sContent          = sEventDesc;
                        oPushNotification.sDeviceID         = sDeviceIDS;
                        oPushNotification.enmLanguage       = this.CurrentApplicationLanguage;
                        oPushNotification.sRecordID         = oResponseResult.ResponseCode;
                        oPushNotification.sOneSignalAppID   = this.CurrentApplicationOneSignalID;
                        oPushNotification.sOneSignalAuthKey = this.CurrentApplicationOneSignalAuthKey;
                        oPushNotification.SendPushNotification();
                        NotificationLogViewModel oNotificationLogViewModel = new NotificationLogViewModel();
                        oNotificationLogViewModel.APPLICATION_ID       = this.CurrentApplicationID;
                        oNotificationLogViewModel.NOTIFICATION_TYPE    = "events";
                        oNotificationLogViewModel.REQUEST_JSON         = oPushNotification.sRequestJSON;
                        oNotificationLogViewModel.RESPONSE_MESSAGE     = oPushNotification.sResponseResult;
                        oNotificationLogViewModel.MOBILE_NUMBERS       = sMobileNumbers;
                        oNotificationLogViewModel.IS_SENT_NOTIFICATION = oPushNotification.bIsSentNotification;
                        oICommonServices.oInsertNotificationLog(oNotificationLogViewModel);
                        #endregion
                    }
                }
                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public JsonResult JInserTicket(TicketViewModel oTicketViewModel)
        {
            Response           oResponseResult   = null;
            string             sRealFileName     = string.Empty;
            string             sModifiedFileName = string.Empty;
            HttpPostedFileBase filebase          = null;
            var oFile = System.Web.HttpContext.Current.Request.Files["TicketImage"];

            if (oFile != null)
            {
                filebase = new HttpPostedFileWrapper(oFile);
                if (filebase.ContentLength > 0)
                {
                    sRealFileName     = filebase.FileName;
                    sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                    oTicketViewModel.DEFAULT_IMAGE = sModifiedFileName;
                }
            }

            oTicketViewModel.APPLICATION_ID          = CurrentApplicationID;
            oTicketViewModel.TICKET_CREATED_PLATFORM = (int)Infrastructure.Core.enmTicketPlatForm.Web;
            oTicketViewModel.CREATED_BY = Convert.ToInt32(CurrentUser.nUserID);

            oResponseResult = this.oITicketServices.oInsertTicket(oTicketViewModel, oTicketViewModel.MobileParticipantId);

            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:

                if (oFile != null)
                {
                    FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                    //DirectoryPath = Saved Application ID + Inserted Ticket ID
                    string sDirectoryPath = Path.Combine(this.CurrentApplicationID.ToString(), oResponseResult.ResponseID.ToString());
                    string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                    oFileAccessService.CreateDirectory(sDirectoryPath);
                    byte[] fileData = null;
                    using (var binaryReader = new BinaryReader(filebase.InputStream))
                    {
                        fileData = binaryReader.ReadBytes(filebase.ContentLength);
                    }
                    oFileAccessService.WirteFileByte(sFullFilePath, fileData);
                }

                #region :: Send Push Notification ::
                List <TicketMobileUserParticipantViewModel> lstTicketMobileUserParticipantViewModel = this.oITicketServices.IlGetTicketMobileUserParticipants(Convert.ToInt32(oResponseResult.ResponseID), -99);
                if (lstTicketMobileUserParticipantViewModel.Count > 0)
                {
                    foreach (var oTicketMobileUserParticipantViewModel in lstTicketMobileUserParticipantViewModel)
                    {
                        if (!oTicketMobileUserParticipantViewModel.DEVICE_ID.Equals(string.Empty))
                        {
                            PushNotification oPushNotification = new PushNotification();
                            oPushNotification.NotificationType  = enmNotificationType.Tickets;
                            oPushNotification.sHeadings         = oTicketMobileUserParticipantViewModel.TICKET_NAME;
                            oPushNotification.sContent          = string.Format("{0} {1}", CurrentUser.sUserFullNameEnglish, oTicketMobileUserParticipantViewModel.PreferedLanguage == Data.Core.Languages.English ? " has been created a ticket" : " تم إنشاء تذكرة");
                            oPushNotification.enmLanguage       = oTicketMobileUserParticipantViewModel.PreferedLanguage;
                            oPushNotification.sDeviceID         = oTicketMobileUserParticipantViewModel.DEVICE_ID;
                            oPushNotification.sOneSignalAppID   = this.CurrentApplicationOneSignalID;
                            oPushNotification.sOneSignalAuthKey = this.CurrentApplicationOneSignalAuthKey;
                            oPushNotification.SendPushNotification();
                            NotificationLogViewModel oNotificationLogViewModel = new NotificationLogViewModel();
                            oNotificationLogViewModel.APPLICATION_ID       = this.CurrentApplicationID;
                            oNotificationLogViewModel.NOTIFICATION_TYPE    = "tickets";
                            oNotificationLogViewModel.REQUEST_JSON         = oPushNotification.sRequestJSON;
                            oNotificationLogViewModel.RESPONSE_MESSAGE     = oPushNotification.sResponseResult;
                            oNotificationLogViewModel.MOBILE_NUMBERS       = oTicketMobileUserParticipantViewModel.PHONE_NUMBER;
                            oNotificationLogViewModel.IS_SENT_NOTIFICATION = oPushNotification.bIsSentNotification;
                            oICommonServices.oInsertNotificationLog(oNotificationLogViewModel);
                        }
                    }
                }
                #endregion

                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }