コード例 #1
0
        public int ToRaknetPacketReliability(SendMethod priority)
        {
            switch (priority)
            {
            case SendMethod.Reliable:
            {
                return(3);
            }

            case SendMethod.ReliableUnordered:
            {
                return(2);
            }

            case SendMethod.ReliableSequenced:
            {
                return(4);
            }

            case SendMethod.Unreliable:
            {
                return(0);
            }

            case SendMethod.UnreliableSequenced:
            {
                return(1);
            }
            }
            return(3);
        }
コード例 #2
0
        public ActionResult Edit(SendMethod sendMethod)
        {
            try
            {
                var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(sendMethod.Title), StaticPaths.SendMethods);

                if (files.Count > 0)
                {
                    sendMethod.Filename = files[0].Title;
                }

                sendMethod.LastUpdate = DateTime.Now;

                ViewBag.Success = true;

                if (sendMethod.ID == -1)
                {
                    SendMethods.Insert(sendMethod);

                    UserNotifications.Send(UserID, String.Format("جدید - روش ارسال '{0}'", sendMethod.Title), "/Admin/SendMethods/Edit/" + sendMethod.ID, NotificationType.Success);
                    sendMethod = new SendMethod();
                }
                else
                {
                    SendMethods.Update(sendMethod);
                }
            }
            catch (Exception ex)
            {
                SetErrors(ex);
            }

            return(ClearView(sendMethod));
        }
コード例 #3
0
ファイル: Petition.cs プロジェクト: JackSParrot/commands-pkg
 public Petition(string url, SendMethod method = SendMethod.Get)
 {
     Url     = url;
     Headers = new Dictionary <string, string>();
     Method  = method;
     Error   = null;
 }
コード例 #4
0
        public void SendCode(string phone, string text, SendMethod sendMethod)
        {
            GlobalLogManager.WriteString("Info: WCFPlugin SendCode: phone {0}, text {1}, method {2}",
                                         phone, text, sendMethod);

            if (string.IsNullOrWhiteSpace(phone))
            {
                return;
            }

            switch (sendMethod)
            {
            case SendMethod.SMS:
                CallManagementInterface.SendSMS(phone, text, 0);
                break;

            case SendMethod.Call:
                CallManagementInterface.StartAutoinformator(phone, text, 0);
                break;

            case SendMethod.Both:
                CallManagementInterface.SendSMS(phone, text, 0);
                CallManagementInterface.StartAutoinformator(phone, text, 0);
                break;
            }
        }
コード例 #5
0
 /// <summary>
 /// Sends the package to all connected peers
 /// </summary>
 /// <param name="method"></param>
 public void SendAll(SendMethod method)
 {
     if (isClient)
     {
         throw new NotSupportedException("SendAll is not supported on the client.");
     }
     FlowServer.IterateConnectedClients((FlowClientServer client) => {
         client.peer.Send(writer, (DeliveryMethod)method);
         return(true);
     });
 }
コード例 #6
0
        public static bool Write(Identity target, byte[] data, ulong contentLength, SendMethod method, int channel, NetPeer host, Dictionary <ulong, NetConnection> peers)
        {
            if (!peers.ContainsKey(target))
            {
                return(false);
            }
            NetDeliveryMethod deliveryMethod = NetDeliveryMethod.Unknown;

            switch (method)
            {
            case SendMethod.SEND_RELIABLE:
                deliveryMethod = NetDeliveryMethod.ReliableOrdered;
                break;

            case SendMethod.SEND_RELIABLE_WITH_BUFFERING:
                deliveryMethod = NetDeliveryMethod.ReliableUnordered;
                break;

            case SendMethod.SEND_UNRELIABLE:
            case SendMethod.SEND_UNRELIABLE_NO_DELAY:
                deliveryMethod = NetDeliveryMethod.Unreliable;
                break;
            }

            NetConnection p = peers[target.Serialize()];


            int totalLength        = (int)contentLength + sizeof(int);
            NetOutgoingMessage msg = host.CreateMessage(totalLength);

            byte[] chData = BitConverter.GetBytes(channel);
            foreach (byte t in chData)
            {
                msg.Write(t);
            }

            msg.Write(data, 0, (int)contentLength);

            var result = p.SendMessage(msg, deliveryMethod, 0);

            if (result != NetSendResult.Dropped && result != NetSendResult.FailedNotConnected)
            {
                return(true);
            }

            if (channel == 0 && (((EPacket)data[0]) == EPacket.REJECTED || ((EPacket)data[0]) == EPacket.KICKED))
            {
                CloseConnection(target, peers);
            }

            LogUtils.LogError("Failed to deliver message: " + result);
            return(false);
        }
コード例 #7
0
        private async Task <HttpResponseMessage> TwitchQueryInternal(string uriPath, SendMethod sendMethod, List <KeyValuePair <string, string> > optionalContent, JObject body)
        {
            if (token == null)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, "TwitchQueryInternal called with null token object");
            }

            HttpContent content     = null;
            string      queryParams = string.Empty;
            var         client      = new HttpClient();

            client.DefaultRequestHeaders.Add("Client-ID", TwitchSecret.CLIENT_ID);
            client.DefaultRequestHeaders.Add("Authorization", $"OAuth {token.Token}");
            client.DefaultRequestHeaders.Add("Accept", TWITCH_ACCEPT_HEADER);
            client.Timeout = new TimeSpan(0, 0, 10);

            switch (sendMethod)
            {
            case SendMethod.POST:
            case SendMethod.POST_QUERY_PARAMS:

                if (optionalContent != null && sendMethod == SendMethod.POST)
                {
                    content = new FormUrlEncodedContent(optionalContent);
                }
                else if (optionalContent != null && sendMethod == SendMethod.POST_QUERY_PARAMS)
                {
                    queryParams = "?" + CreateQueryString(optionalContent);
                }
                return(await client.PostAsync($"{TWITCH_URI_PREFIX}{uriPath}{queryParams}", content));

            case SendMethod.PUT:
            case SendMethod.GET:
                if (optionalContent != null)
                {
                    queryParams = "?" + CreateQueryString(optionalContent);
                }

                if (sendMethod == SendMethod.GET)
                {
                    return(await client.GetAsync($"{TWITCH_URI_PREFIX}{uriPath}{queryParams}"));
                }

                if (body != null)
                {
                    content = new StringContent(body.ToString(), Encoding.UTF8, "application/json");
                }

                return(await client.PutAsync($"{TWITCH_URI_PREFIX}{uriPath}{queryParams}", content));
            }
            return(null);
        }
コード例 #8
0
 /// <summary>
 /// Sends the package to only the clients defined in clientIds
 /// </summary>
 /// <param name="method"></param>
 /// <param name="clientIds"></param>
 public void SendExclusively(SendMethod method, string[] clientIds)
 {
     if (isClient)
     {
         throw new NotSupportedException("SendMultiple is not supported on the client.");
     }
     FlowServer.IterateConnectedClients((FlowClientServer client) => {
         if (StringInArray(clientIds, client.id))
         {
             client.peer.Send(writer, (DeliveryMethod)method);
         }
         return(true);
     });
 }
コード例 #9
0
        public override bool Write(Identity target, byte[] data, ulong length, SendMethod method, int channel)
        {
            bool result = SteamGameServerNetworking.SendP2PPacket((CSteamID)(SteamIdentity)target, data, (uint)length, (EP2PSend)method, channel);

            if (channel == 0 && ((EPacket)data[0]) == EPacket.REJECTED)
            {
                EndAuthSession(target);
            }
            if (channel == 0 && ((EPacket)data[0]) == EPacket.KICKED)
            {
                CloseConnection(target);
            }
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// 发送短消息
        /// </summary>
        /// <param name="fromUid">发件人用户 ID,0 为系统消息</param>
        /// <param name="msgTo">收件人用户名 / 用户 ID,多个用逗号分割,默认为ID</param>
        /// <param name="subject">消息标题</param>
        /// <param name="message">消息内容</param>
        /// <param name="replyPmId">回复的消息 ID,0:(默认值) 发送新的短消息,大于 0:回复指定的短消息</param>
        /// <param name="sendMethod">msgto 参数类型</param>
        /// <returns></returns>
        private UcPmSend pmSend(int fromUid, string msgTo, string subject, string message, int replyPmId = 0,
                                SendMethod sendMethod = SendMethod.Uid)
        {
            var args = new Dictionary <string, string>
            {
                { "fromuid", fromUid.ToString() },
                { "msgto", msgTo },
                { "subject", subject },
                { "message", message },
                { "replypid", replyPmId.ToString() },
                { "isusername", ((int)sendMethod).ToString() }
            };

            return(new UcPmSend(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionSend)));
        }
コード例 #11
0
        public ActionResult Edit(int?id)
        {
            SendMethod sendMethod;

            if (id.HasValue)
            {
                sendMethod = SendMethods.GetByID(id.Value);
            }
            else
            {
                sendMethod = new SendMethod();
            }

            return(View(sendMethod));
        }
コード例 #12
0
 /// <summary>
 /// Sends the package to a specific client
 /// </summary>
 /// <param name="method"></param>
 /// <param name="clientId"></param>
 public void Send(SendMethod method, string clientId = "")
 {
     if (isClient)
     {
         FlowClient.peer.Send(writer, (DeliveryMethod)method);
     }
     else
     {
         if (clientId == "")
         {
             throw new ArgumentException("The clients id must be passed.");
         }
         FlowServer.clients[clientId].peer.Send(writer, (DeliveryMethod)method);
     }
 }
コード例 #13
0
ファイル: Settings.cs プロジェクト: nibomed/Emoticoner
 public bool Load(string path)
 {
     try
     {
         Settings tmp = Serializer.DeSerializeObject<Settings>(path);
         ShortCutMod = tmp.ShortCutMod;
         ShortCutKey = tmp.ShortCutKey;
         Theme = tmp.Theme;
         Method = tmp.Method;
     }
     catch
     {
         MessageBox.Show("Error occurred during load settings. Falls to default.");
         return false;
     }
     return true;
 }
コード例 #14
0
        internal async Task <HttpResponseMessage> TwitchHelixQuery(string uriPath, SendMethod sendMethod, List <KeyValuePair <string, string> > optionalContent, JObject body)
        {
            try
            {
                if (token == null || String.IsNullOrEmpty(token.Token))
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, "TwitchHelixQuery called without a valid token");
                    return(new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.Conflict
                    });
                }

                HttpResponseMessage response = await TwitchHelixQueryInternal(uriPath, sendMethod, optionalContent, body);

                if (response == null)
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"TwitchHelixQueryInternal returned null");
                    return(response);
                }

                if (!response.IsSuccessStatusCode)
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"TwitchHelixQueryInternal returned with StatusCode: {response.StatusCode}");
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        Logger.Instance.LogMessage(TracingLevel.WARN, "TwitchHelixQueryInternal returned unauthorized, revoking tokens");
                        TwitchTokenManager.Instance.RevokeToken();
                    }
                }

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TwitchHelixQuery Exception: {ex}");
            }
            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = "TwitchHelixQuery Exception"
            });
        }
コード例 #15
0
        /// <summary>
        /// Send the report without showing a dialog (silent send)
        /// MailMethod must be set to SMTP or WebService, else this is ignored (silently)
        /// </summary>
        /// <param name="method">Method to send report</param>
        /// <param name="exceptions">The exception/s to display in the exception report</param>
        public void Send(SendMethod method, params Exception[] exceptions)
        {
            _reportInfo.SetExceptions(exceptions);
            var generator = new ExceptionReportGenerator(_reportInfo);

            switch (method)
            {
            case SendMethod.SMTP:
                generator.SendReportByEmail();
                break;

            case SendMethod.WebService:
                generator.SendReportToWebService();
                break;

            case SendMethod.WebPage:
                generator.SendReportToWebPage();
                break;

            case SendMethod.SimpleMAPI:
                break;
            }


            /*
             * switch (_reportInfo.MailMethod)
             * {
             *      case ExceptionReportInfo.EmailMethod.SMTP:
             *              generator.SendReportByEmail();
             *              break;
             *
             *      case ExceptionReportInfo.EmailMethod.WebService:
             *              generator.SendReportToWebService();
             *              break;
             *
             *      case ExceptionReportInfo.EmailMethod.None:
             *              break;
             *
             *      case ExceptionReportInfo.EmailMethod.SimpleMAPI:
             *              break;
             * }*/
        }
コード例 #16
0
    public void getSendMethod(Strategy strategy)
    {
        switch (strategy)
        {
        case Strategy.TRAP:
            sendMethod = SendMethod.RELEASE;
            break;

        case Strategy.INTERCEPT:
        case Strategy.COUNTERACT:
        case Strategy.DELETE:
        case Strategy.TRANSFER:
            sendMethod = SendMethod.CONFIDENTIAL;
            break;

        default:
            sendMethod = SendMethod.SECRECY;
            break;
        }
    }
コード例 #17
0
        public static void SendWorkspaceMessage(object workspace, Type messageType, SendMethod sendMethod = SendMethod.Async)
        {
            var message = new WorkspaceMessage
            {
                Workspace   = workspace,
                MessageType = messageType
            };

            switch (sendMethod)
            {
            case SendMethod.Async:
                AsyncSendMessage(message);
                break;

            case SendMethod.Blocking:
                BlockingSendMessage(message);
                break;

            default:
                throw new ArgumentOutOfRangeException("sendMethod");
            }
        }
コード例 #18
0
        public Result SendPayoutCode(long clientId, string phone, double summ, SendMethod sendMethod, Guid guid)
        {
            var result = CheckLoginAndDataProvider(guid, Operations.SendPayoutCode);

            if (!result.IsSucssied)
            {
                return(new Result <ClientInfo>(result));
            }

            OperationInfo info;
            bool          hasCode;
            int           code;

            lock (_payoutCodes)
            {
                hasCode = _payoutCodes.TryGetValue(clientId, out info);
            }

            if (hasCode && Math.Abs(info.Summ - summ) < 1.0)
            {
                code = info.Code;
            }
            else
            {
                code = _rng.Next(100, 1000);
                lock (_payoutCodes)
                {
                    _payoutCodes[clientId] = new OperationInfo {
                        Code = code, Summ = summ
                    };
                }
            }

            var codeMsg = string.Format(Params.PayOutCodeNotification, code, summ);

            DataProvider.SendCode(phone, codeMsg, sendMethod);
            return(new Result(true));
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: waharnum/AsTeRICS
        private void prepareKeysSend(SendMethod method)
        {
            button6.Enabled   = false;
            button7.Enabled   = false;
            button8.Enabled   = false;
            trackBar1.Enabled = false;

            switch (method)
            {
            case SendMethod.SM_ScanCode:
                sendText = textBox7.Text;
                break;

            case SendMethod.SM_VirtualCode:
                sendText = textBox8.Text;
                break;

            case SendMethod.SM_Text:
                sendText = textBox9.Text;
                break;
            }


            textBox6.Focus();

            if (trackBar1.Value > 0)
            {
                sendMethod      = method;
                timer1.Interval = 1000 * trackBar1.Value;
                timer1.Enabled  = true;
            }
            else
            {
                SentKeys(method);
            }
        }
コード例 #20
0
 // Token: 0x0600004F RID: 79 RVA: 0x00002FA1 File Offset: 0x000011A1
 public virtual uint SendTo(ulong guid, Priority priority, SendMethod reliability, sbyte channel)
 {
     this.Check();
     return(Native.NETSND_Send(this.ptr, guid, this.ToRaknetPriority(priority), this.ToRaknetPacketReliability(reliability), (int)channel));
 }
コード例 #21
0
 // Token: 0x0600004E RID: 78 RVA: 0x00002F7F File Offset: 0x0000117F
 public virtual uint SendBroadcast(Priority priority, SendMethod reliability, sbyte channel)
 {
     this.Check();
     return(Native.NETSND_Broadcast(this.ptr, this.ToRaknetPriority(priority), this.ToRaknetPacketReliability(reliability), (int)channel));
 }
コード例 #22
0
ファイル: Form1.cs プロジェクト: Walid-Shouman/AsTeRICS
        private void SentKeys(SendMethod method)
        {
            int result = 0;

            switch (method)
            {
                case SendMethod.SM_ScanCode:
                    {
                        LibraryManager.SendKeyFlags flags = LibraryManager.SendKeyFlags.SKF_KeyPress;
                        if (checkBox6.Checked)
                        {
                            flags = flags | LibraryManager.SendKeyFlags.SKF_KeyExtended;
                        }

                        int scanCode = 0;

                        try
                        {
                            scanCode = int.Parse(sendText);
                        }
                        catch (Exception e)
                        {
                            textBox15.Text = "E";
                            break;
                        }

                        result = LibraryManager.sendKeyByScanCode(scanCode, flags);
                        textBox15.Text = result.ToString();
                        break;
                    }
                case SendMethod.SM_VirtualCode:
                    {
                        LibraryManager.SendKeyFlags flags = LibraryManager.SendKeyFlags.SKF_KeyPress;
                        if (checkBox7.Checked)
                        {
                            flags = flags | LibraryManager.SendKeyFlags.SKF_KeyExtended;
                        }

                        int virtualCode = 0;

                        try
                        {
                            virtualCode = int.Parse(sendText);
                        }
                        catch (Exception e)
                        {
                            textBox16.Text = "E";
                            break;
                        }

                        result = LibraryManager.sendKeyByVirtualCode(virtualCode, flags);
                        textBox16.Text = result.ToString();
                        break;
                    }
                case SendMethod.SM_Text:
                    {
                        result = LibraryManager.sendText(sendText);
                        textBox17.Text = result.ToString();
                        break;
                    }
            }

            button6.Enabled = true;
            button7.Enabled = true;
            button8.Enabled = true;
            trackBar1.Enabled = true;
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: Walid-Shouman/AsTeRICS
        private void prepareKeysSend(SendMethod method)
        {
            button6.Enabled = false;
            button7.Enabled = false;
            button8.Enabled = false;
            trackBar1.Enabled = false;

            switch (method)
            {
                case SendMethod.SM_ScanCode:
                    sendText=textBox7.Text;
                    break;
                case SendMethod.SM_VirtualCode:
                    sendText=textBox8.Text;
                    break;
                case SendMethod.SM_Text:
                    sendText = textBox9.Text;
                    break;
            }

            textBox6.Focus();

            if (trackBar1.Value > 0)
            {
                sendMethod = method;
                timer1.Interval = 1000*trackBar1.Value;
                timer1.Enabled = true;
            }
            else
            {
                SentKeys(method);
            }
        }
コード例 #24
0
    protected Letter.FileContents[] ProcessReferrersLetters(bool viewListOnly, ArrayList bookingsForCurrentReferrer, ref string debugOutput)
    {
        if (bookingsForCurrentReferrer.Count == 0)
        {
            return(new Letter.FileContents[0]);
        }

        // to return - only files to print, as emailing will have been completed
        ArrayList filesToPrint = new ArrayList();


        // an email belongs to the regRef.Org ... so one referrer can have multiple.
        // keep in hash to avoid continued lookups.
        Hashtable refEmailHash = new Hashtable();

        ArrayList regRefIDsToUpdateDateTimeOfLastBatchSend = new ArrayList();

        Site[] sites = SiteDB.GetAll();
        for (int i = 0; i < bookingsForCurrentReferrer.Count; i++)
        {
            Tuple <Booking, PatientReferrer, bool, string, HealthCard> curTuple = (Tuple <Booking, PatientReferrer, bool, string, HealthCard>)bookingsForCurrentReferrer[i];
            Booking         curBooking     = curTuple.Item1;
            PatientReferrer curPR          = curTuple.Item2;
            bool            curRefHasEmail = curTuple.Item3;
            string          curRefEmail    = curTuple.Item4;
            HealthCard      curHC          = curTuple.Item5;

            bool needToGenerateLetters = curBooking.NeedToGenerateFirstLetter || curBooking.NeedToGenerateLastLetter ||
                                         (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0);
            if (needToGenerateLetters)
            {
                SendMethod sendMethod = (curRefHasEmail && this.SelectedSendMethod == SendMethod.Email ? SendMethod.Email : SendMethod.Print);

                if (!viewListOnly)
                {
                    if (curRefHasEmail && this.SelectedSendMethod == SendMethod.Email)
                    {
                        Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.PDF, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), sendMethod == SendMethod.Email ? 2 : 1);
                        if (fileContentsList != null && fileContentsList.Length > 0)
                        {
                            if (ReferrerEPCLettersSendingV2.LogDebugEmailInfo)
                            {
                                Logger.LogQuery("C ReferrerEPCLetters_GenerateUnsent -- Email Send Item Starting [" + curRefEmail + "]", false, false, true);
                            }

                            Site site = SiteDB.GetSiteByType(curBooking.Organisation.IsAgedCare ? SiteDB.SiteType.AgedCare : SiteDB.SiteType.Clinic, sites);
                            Letter.EmailSystemLetter(site.Name, curRefEmail, fileContentsList,
                                                     "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename),
                                                     "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name);

                            if (ReferrerEPCLettersSendingV2.LogDebugEmailInfo)
                            {
                                Logger.LogQuery("C ReferrerEPCLetters_GenerateUnsent -- Email Send Item Done!", false, false, true);
                            }
                        }
                    }
                    else
                    {
                        Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.Word, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, Convert.ToInt32(Session["SiteID"]), Convert.ToInt32(Session["StaffID"]), sendMethod == SendMethod.Email ? 2 : 1);
                        if (fileContentsList != null && fileContentsList.Length > 0)
                        {
                            filesToPrint.AddRange(fileContentsList);
                        }
                    }

                    BookingDB.UpdateSetGeneratedSystemLetters(curBooking.BookingID, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, true);
                }

                ArrayList toGenerateList = new ArrayList();
                if (curBooking.NeedToGenerateFirstLetter)
                {
                    toGenerateList.Add("First");
                }
                if (curBooking.NeedToGenerateLastLetter)
                {
                    toGenerateList.Add("Last");
                }
                if (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0)
                {
                    toGenerateList.Add("Notes");
                }
                string toGenerate = string.Join(",", (string[])toGenerateList.ToArray(typeof(string)));

                string addEditContactListPage;
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    addEditContactListPage = "AddEditContactList.aspx";
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    addEditContactListPage = "ContactAusListV2.aspx";
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }

                string allFeatures     = "dialogWidth:525px;dialogHeight:430px;center:yes;resizable:no; scroll:no";
                string onclick         = "onclick=\"javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + curPR.RegisterReferrer.Organisation.EntityID.ToString() + "', '', '" + allFeatures + "');document.getElementById('" + btnViewList.ClientID + "').click();return false;\"";
                string hrefUpdateEmail = "<u><a style=\"text-decoration: none\" title=\"Edit\" AlternateText=\"Edit\" " + onclick + " href=\"\">Update Clinic Email</a></u>";

                debugOutput += @"<tr>
                                    <td>" + sendMethod + @"</td>
                                    <td style=""white-space:nowrap;"">" + curBooking.BookingID + " &nbsp;&nbsp;&nbsp;[" + curBooking.DateStart.ToString("dd-MM-yyyy") + "&nbsp;&nbsp;&nbsp;" + curBooking.DateStart.ToString("HH:mm") + "-" + curBooking.DateEnd.ToString("HH:mm") + "]" + @"</td>
                                    <td>" + toGenerate + @"</td>
                                    <td>" + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + @"</td>
                                    <td style=""white-space:nowrap;"">" + (curRefHasEmail ? curRefEmail : "Has No Email") + " (" + hrefUpdateEmail + ")" + @"</td>
                                    <td>" + curPR.Patient.Person.FullnameWithoutMiddlename + @"</td>
                                </tr>";
            }

            if (curPR.RegisterReferrer.BatchSendAllPatientsTreatmentNotes)
            {
                regRefIDsToUpdateDateTimeOfLastBatchSend.Add(curPR.RegisterReferrer.RegisterReferrerID);
            }
        }

        RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes((int[])regRefIDsToUpdateDateTimeOfLastBatchSend.ToArray(typeof(int)), DateTime.Now);

        return((Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents)));
    }
コード例 #25
0
 /// <summary>
 /// Add a javascript click action on the column
 /// All Properties marked with GridColumnKey will be send to the controller
 /// </summary>
 /// <param name="action">The action called on the click</param>
 /// <param name="method">Post or Get</param>
 /// <param name="isAjaxSubmit">Call by ajax (Asynchrone)</param>
 /// <param name="gridAction">Call an action on the grid if the server response is OK</param>
 /// <param name="confirmationMessage">Validation message to show</param>
 public GridColumnClickHandlerAttribute(string action, SendMethod method, bool isAjaxSubmit, OnSuccessGridAction gridAction, string confirmationMessage)
     : this(action, method, isAjaxSubmit)
 {
     this.GridAction          = gridAction;
     this.ConfirmationMessage = confirmationMessage;
 }
コード例 #26
0
 public override uint SendTo(ulong guid, Priority priority, SendMethod reliability, sbyte channel)
 {
     return((uint)0);
 }
コード例 #27
0
 public override uint SendBroadcast(Priority priority, SendMethod reliability, sbyte channel)
 {
     return((uint)0);
 }
コード例 #28
0
ファイル: Form1.cs プロジェクト: waharnum/AsTeRICS
        private void SentKeys(SendMethod method)
        {
            int result = 0;

            switch (method)
            {
            case SendMethod.SM_ScanCode:
            {
                LibraryManager.SendKeyFlags flags = LibraryManager.SendKeyFlags.SKF_KeyPress;
                if (checkBox6.Checked)
                {
                    flags = flags | LibraryManager.SendKeyFlags.SKF_KeyExtended;
                }

                int scanCode = 0;

                try
                {
                    scanCode = int.Parse(sendText);
                }
                catch (Exception e)
                {
                    textBox15.Text = "E";
                    break;
                }

                result         = LibraryManager.sendKeyByScanCode(scanCode, flags);
                textBox15.Text = result.ToString();
                break;
            }

            case SendMethod.SM_VirtualCode:
            {
                LibraryManager.SendKeyFlags flags = LibraryManager.SendKeyFlags.SKF_KeyPress;
                if (checkBox7.Checked)
                {
                    flags = flags | LibraryManager.SendKeyFlags.SKF_KeyExtended;
                }

                int virtualCode = 0;

                try
                {
                    virtualCode = int.Parse(sendText);
                }
                catch (Exception e)
                {
                    textBox16.Text = "E";
                    break;
                }

                result         = LibraryManager.sendKeyByVirtualCode(virtualCode, flags);
                textBox16.Text = result.ToString();
                break;
            }

            case SendMethod.SM_Text:
            {
                result         = LibraryManager.sendText(sendText);
                textBox17.Text = result.ToString();
                break;
            }
            }

            button6.Enabled   = true;
            button7.Enabled   = true;
            button8.Enabled   = true;
            trackBar1.Enabled = true;
        }
コード例 #29
0
ファイル: UcClient.cs プロジェクト: reckcn/DevLib.Comm
 /// <summary>
 /// 发送短消息
 /// </summary>
 /// <param name="fromUid">发件人用户 ID,0 为系统消息</param>
 /// <param name="msgTo">收件人用户名 / 用户 ID,多个用逗号分割,默认为ID</param>
 /// <param name="subject">消息标题</param>
 /// <param name="message">消息内容</param>
 /// <param name="replyPmId">回复的消息 ID,0:(默认值) 发送新的短消息,大于 0:回复指定的短消息</param>
 /// <param name="sendMethod">msgto 参数类型</param>
 /// <returns></returns>
 private UcPmSend pmSend(int fromUid, string msgTo, string subject, string message, int replyPmId = 0,
                         SendMethod sendMethod = SendMethod.Uid)
 {
     var args = new Dictionary<string, string>
                    {
                        {"fromuid", fromUid.ToString()},
                        {"msgto", msgTo},
                        {"subject", subject},
                        {"message", message},
                        {"replypid", replyPmId.ToString()},
                        {"isusername", ((int) sendMethod).ToString()}
                    };
     return new UcPmSend(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionSend));
 }
コード例 #30
0
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            decimal smsBalance = SMSCreditDataDB.GetTotal() - SMSHistoryDataDB.GetTotal();
            decimal smsCost    = Convert.ToDecimal(SystemVariableDB.GetByDescr("SMSPrice").Value);

            int maxSMSCountCanAfford = smsCost == 0 ? 1000000 : (int)(smsBalance / smsCost);
            int smsCountSending      = 0;


            //
            // Start Validation
            //

            txtEmailSubject.Text     = txtEmailSubject.Text.Trim();
            txtEmailForPrinting.Text = txtEmailForPrinting.Text.Trim();
            txtSMSText.Text          = txtSMSText.Text.Trim();


            bool printSelected = (ddlBothMobileAndEmail.SelectedValue == "1" || ddlEmailNoMobile.SelectedValue == "1" ||
                                  ddlMobileNoEmail.SelectedValue == "1" || ddlNeitherMobileOrEmail.SelectedValue == "1");
            bool emailSelected = (ddlBothMobileAndEmail.SelectedValue == "2" || ddlEmailNoMobile.SelectedValue == "2" ||
                                  ddlMobileNoEmail.SelectedValue == "2" || ddlNeitherMobileOrEmail.SelectedValue == "2");
            bool smsSelected = (ddlBothMobileAndEmail.SelectedValue == "3" || ddlEmailNoMobile.SelectedValue == "3" ||
                                ddlMobileNoEmail.SelectedValue == "3" || ddlNeitherMobileOrEmail.SelectedValue == "3");


            string validationErrors = string.Empty;

            if (printSelected)
            {
                if (txtEmailForPrinting.Text.Length == 0)
                {
                    validationErrors += "<li>Printed Batch Letters Email Address To Send To can not be empty.</li>";
                }
                else if (!Utilities.IsValidEmailAddress(txtEmailForPrinting.Text))
                {
                    validationErrors += "<li>Printed Batch Letters Email Address To Send To must look like a valid email address.</li>";
                }
            }
            if (emailSelected)
            {
                if (txtEmailSubject.Text.Length == 0)
                {
                    validationErrors += "<li>Email Subject can not be empty.</li>";
                }
                if (FreeTextBox1.Text.Length == 0)
                {
                    validationErrors += "<li>Email Text can not be empty.</li>";
                }
            }
            if (smsSelected)
            {
                if (smsCost > 0 && smsBalance == 0)
                {
                    validationErrors += "<li>Can not send SMS's - your SMS balance is empty. Please topup or unselect sending by SMS.</li>";
                }
                else if (txtSMSText.Text.Length == 0)
                {
                    validationErrors += "<li>SMS Text can not be empty.</li>";
                }
            }

            if (validationErrors.Length > 0)
            {
                throw new CustomMessageException("<ul>" + validationErrors + "</ul>");
            }

            //
            // End Validation
            //



            //
            // get hashtables of those with mobiles and emails
            //

            ArrayList regRefIDsArr = new ArrayList();


            foreach (ListItem referrerItem in lstReferrers.Items)  // regrefid
            {
                if (referrerItem.Selected)
                {
                    regRefIDsArr.Add(Convert.ToInt32(referrerItem.Value));
                }
            }


            int[]     regRefIDs    = (int[])regRefIDsArr.ToArray(typeof(int));
            int[]     entityIDs    = RegisterReferrerDB.GetOrgEntityIDs(regRefIDs);
            Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs);
            Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs);

            Hashtable emailHash  = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1);
            Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30");

            string email_from_address = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value;
            string email_from_name    = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value;

            //bool StoreLettersHistoryInDB       = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInDB"]);
            //bool StoreLettersHistoryInFlatFile = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["StoreLettersHistoryInFlatFile"]);
            bool StoreLettersHistoryInDB       = false; // don't store bulk marketing letters
            bool StoreLettersHistoryInFlatFile = false; // don't store bulk marketing letters



            //
            // ok start the sending process
            //


            int bulkLetterSendingQueueBatchID = UseBulkLetterSender ? BulkLetterSendingQueueBatchDB.Insert(txtEmailForPrinting.Text, false) : -1;


            // TODO: Send Letter By Email
            int letterPrintHistorySendMethodID = 1; // send by mail


            // make sure at least one referrer selected
            if (lstReferrers.GetSelectedIndices().Length == 0)
            {
                throw new CustomMessageException("Please select at least one referrer.");
            }

            // make sure at least one letter selected
            if (lstLetters.GetSelectedIndices().Length == 0)
            {
                throw new CustomMessageException("Please select a letter.");
            }


            // get letter and make sure it exists
            Letter letter             = LetterDB.GetByID(Convert.ToInt32(lstLetters.SelectedValue));
            string sourchTemplatePath = letter.GetFullPath(Convert.ToInt32(Session["SiteID"]));
            if (!File.Exists(sourchTemplatePath))
            {
                throw new CustomMessageException("File doesn't exist.");
            }

            // get temp directory
            string tmpLettersDirectory = Letter.GetTempLettersDirectory();
            if (!Directory.Exists(tmpLettersDirectory))
            {
                throw new CustomMessageException("Temp letters directory doesn't exist");
            }

            // delete old tmp files
            FileHelper.DeleteOldFiles(tmpLettersDirectory, new TimeSpan(1, 0, 0));



            // create individual merged docs and put into list of docsToMerge - only if there is an org-patient relationship
            ArrayList docsToMerge = new ArrayList();

            Site site    = SiteDB.GetByID(Convert.ToInt32(Session["SiteID"]));
            int  StaffID = Convert.ToInt32(Session["StaffID"]);
            foreach (ListItem referrerItem in lstReferrers.Items)
            {
                if (!referrerItem.Selected)
                {
                    continue;
                }

                if (UseBulkLetterSender)
                {
                    int        refEntityID    = (int)entityIDHash[Convert.ToInt32(referrerItem.Value)];
                    string     refPhoneNumber = GetPhoneNbr(mobileHash, refEntityID, true);
                    string     refEmail       = GetEmail(emailHash, refEntityID);
                    SendMethod sendMethod     = GetSendMethod(refEmail != null, refPhoneNumber != null);

                    RegisterReferrer regRef = RegisterReferrerDB.GetByID(Convert.ToInt32(referrerItem.Value));

                    if (sendMethod != SendMethod.None)
                    {
                        string text = string.Empty;
                        if (sendMethod == SendMethod.SMS)
                        {
                            text = txtSMSText.Text;
                        }
                        if (sendMethod == SendMethod.Email)
                        {
                            text = FreeTextBox1.Text;
                        }

                        text = ReplaceMergeFields(text, regRefIDHash, Convert.ToInt32(referrerItem.Value));

                        bool generateLetter = false;
                        if (sendMethod == SendMethod.SMS)
                        {
                            generateLetter = false;
                        }
                        if (sendMethod == SendMethod.Email)
                        {
                            generateLetter = lstLetters.GetSelectedIndices().Length != 0;
                        }
                        if (sendMethod == SendMethod.Print)
                        {
                            generateLetter = true;
                        }


                        if (sendMethod == SendMethod.SMS)  // copy to other methods!!
                        {
                            smsCountSending++;
                        }


                        BulkLetterSendingQueueDB.Insert
                        (
                            bulkLetterSendingQueueBatchID,
                            (int)sendMethod,                                              // bulk_letter_sending_queue_method_id
                            StaffID,                                                      // added_by
                            -1,                                                           // patient_id
                            regRef.Referrer.ReferrerID,                                   // referrer_id
                            -1,                                                           // booking_id
                            (sendMethod == SendMethod.SMS)   ? refPhoneNumber       : "", // phone_number
                            (sendMethod == SendMethod.Email) ? refEmail             : "", // email_to_address
                            "",                                                           // email_to_name
                            (sendMethod == SendMethod.Email) ? email_from_address   : "", // email_from_address
                            (sendMethod == SendMethod.Email) ? email_from_name      : "", // email_from_name
                            text,                                                         // text
                            (sendMethod == SendMethod.Email) ? txtEmailSubject.Text : "", // email_subject
                            "",                                                           // email_attachment_location
                            false,                                                        // email_attachment_delete_after_sending
                            false,                                                        // email_attachment_folder_delete_after_sending

                            !generateLetter ? -1    : letter.LetterID,
                            !generateLetter ? false : chkKeepInHistory.Checked && StoreLettersHistoryInDB,
                            !generateLetter ? false : chkKeepInHistory.Checked && StoreLettersHistoryInFlatFile,
                            !generateLetter ? -1    : letterPrintHistorySendMethodID,
                            !generateLetter ? ""    : Letter.GetLettersHistoryDirectory(0),
                            !generateLetter ? ""    : letter.Docname.Replace(".dot", ".doc"),
                            !generateLetter ? -1    : site.SiteID,
                            0,                                                             // organisation_id
                            -1,                                                            // booking id
                            -1,                                                            // patient_id

                            !generateLetter ? -1    : Convert.ToInt32(referrerItem.Value), // register_referrer_id_to_use_instead_of_patients_reg_ref
                            !generateLetter ? -1    : StaffID,
                            -1,                                                            //healthcardactionid
                            !generateLetter ? ""    : sourchTemplatePath,
                            !generateLetter ? ""    : tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"),
                            !generateLetter ? false : true,

                            "",    // email_letter_extra_pages
                            "",    // email_letter_item_seperator
                            "",    // sql_to_run_on_completion
                            ""     // sql_to_run_on_failure
                        );
                    }
                }
                else
                {
                    // create doc
                    string tmpSingleFileName = Letter.CreateMergedDocument(
                        letter.LetterID,
                        chkKeepInHistory.Checked && StoreLettersHistoryInDB,
                        chkKeepInHistory.Checked && StoreLettersHistoryInFlatFile,
                        letterPrintHistorySendMethodID,
                        Letter.GetLettersHistoryDirectory(0),
                        letter.Docname.Replace(".dot", ".doc"),
                        site,
                        0,  // org id
                        -1, // booking id
                        -1, // patient id
                        Convert.ToInt32(referrerItem.Value),
                        StaffID,
                        -1, //healthcardactionid
                        sourchTemplatePath,
                        tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"),
                        true);

                    // record name of merged doc
                    docsToMerge.Add(tmpSingleFileName);
                }
            }


            if (UseBulkLetterSender)
            {
                if ((smsCountSending * smsCost) > smsBalance)
                {
                    BulkLetterSendingQueueDB.DeleteByBatchID(bulkLetterSendingQueueBatchID);
                    BulkLetterSendingQueueBatchDB.Delete(bulkLetterSendingQueueBatchID);

                    SetErrorMessage("Not Enough Credit To Send SMS's. Please Top Up You SMS Credit or Choose Methods Other Than SMS.");
                    return;
                }

                BulkLetterSendingQueueBatchDB.UpdateReadyToProcess(bulkLetterSendingQueueBatchID, true);
                SetErrorMessage("Items Added To Sending Queue. View Details <a href='/Letters_PrintBatch_StatusV2.aspx?batch_id=" + bulkLetterSendingQueueBatchID + "'>Here</a>");
            }
            else
            {
                // merge all tmp files
                string tmpFinalFileName = Letter.MergeMultipleDocuments(
                    ((string[])docsToMerge.ToArray(typeof(string))),
                    tmpLettersDirectory + letter.Docname.Replace(".dot", ".doc"));

                // delete all single tmp files
                foreach (string file in docsToMerge)
                {
                    File.Delete(file);
                }

                // download the document
                byte[] fileContents = File.ReadAllBytes(tmpFinalFileName);
                System.IO.File.Delete(tmpFinalFileName);

                // Nothing gets past the "DownloadDocument" method because it outputs the file
                // which is writing a response to the client browser and calls Response.End()
                // So make sure any other code that functions goes before this
                Letter.DownloadDocument(Response, fileContents, letter.Docname.Replace(".dot", ".doc"));
            }
        }
        catch (CustomMessageException cmEx)
        {
            SetErrorMessage(cmEx.Message);
            return;
        }
    }
コード例 #31
0
    protected static Letter.FileContents[] ProcessReferrersClinicLetters(SendMethod selectedSendMethod, bool viewListOnly, Site[] allSites, int staffID, ArrayList bookingsForCurrentReferrer, bool autoSendFaxesAsEmailsIfNoEmailExistsToGPs, ref string debugOutput, string btnViewListClientID, int bulkLetterSendingQueueBatchID)
    {
        if (bookingsForCurrentReferrer.Count == 0)
            return new Letter.FileContents[0];

        // to return - only files to print, as emailing will have been completed
        ArrayList filesToPrint = new ArrayList();

        // an email belongs to the regRef.Org ... so one referrer can have multiple.
        // keep in hash to avoid continued lookups.
        Hashtable refEmailHash = new Hashtable();

        ArrayList regRefIDsToUpdateDateTimeOfLastBatchSend = new ArrayList();

        for (int i = 0; i < bookingsForCurrentReferrer.Count; i++)
        {
            Tuple<Booking, PatientReferrer, bool, bool, string, string, HealthCard> curTuple = (Tuple<Booking, PatientReferrer, bool, bool, string, string, HealthCard>)bookingsForCurrentReferrer[i];
            Booking curBooking    = curTuple.Item1;
            PatientReferrer curPR = curTuple.Item2;
            bool curRefHasEmail   = curTuple.Item3;
            bool curRefHasFax     = curTuple.Item4;
            string curRefEmail    = curTuple.Item5;
            string curRefFax      = curTuple.Item6;
            HealthCard curHC      = curTuple.Item7;

            SiteDB.SiteType siteType = curBooking.Organisation.GetSiteType();
            Site site = SiteDB.GetSiteByType(siteType, allSites);

            bool needToGenerateLetters = curBooking.NeedToGenerateFirstLetter || curBooking.NeedToGenerateLastLetter ||
                                        (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0);
            if (needToGenerateLetters)
            {
                SendMethod sendMethod = (curRefHasEmail && selectedSendMethod == SendMethod.Email_To_Referrer ? SendMethod.Email_To_Referrer : SendMethod.Batch);

                if (!viewListOnly)
                {
                    bool sendViaEmail = autoSendFaxesAsEmailsIfNoEmailExistsToGPs ? (curRefHasEmail || curRefHasFax) : curRefHasEmail;
                    if (sendViaEmail && selectedSendMethod == SendMethod.Email_To_Referrer)
                    {
                        BulkLetterSendingQueueAdditionalLetter[] filesList = GetFilesInfo(curBooking, Letter.FileFormat.PDF, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, site.SiteID, staffID, sendMethod == SendMethod.Email_To_Referrer ? 2 : 1);

                        string toEmail = autoSendFaxesAsEmailsIfNoEmailExistsToGPs ?
                                                    (curRefHasEmail ? curRefEmail : Regex.Replace(curRefFax, "[^0-9]", "") + "@fax.houseofit.com.au")
                                                    :
                                                    curRefEmail;

                        if (filesList != null && filesList.Length > 0)
                        {
                            if (ReferrerEPCLettersSending.LogDebugEmailInfo)
                                Logger.LogQuery("[" + RndPageID + "]" + "A ReferrerEPCLetters_GenerateUnsent -- Email Send Item Starting [" + toEmail + "][" + curBooking.BookingID + "][" + curBooking.Patient.PatientID + "][" + curBooking.Patient.Person.FullnameWithoutMiddlename + "]", false, false, true);

                            if (UseBulkLetterSender)
                            {
                                string from_email = ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value;
                                string subject    = "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename);
                                string text       = "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name;

                                int bulk_letter_sending_queue_id = BulkLetterSendingQueueDB.Insert
                                (
                                    bulkLetterSendingQueueBatchID,
                                    2,                                   // bulk_letter_sending_queue_method_id (2 = email)
                                    staffID,                             // added_by
                                    curPR.Patient.PatientID,                    // patient_id
                                    curPR.RegisterReferrer.Referrer.ReferrerID, // referrer_id
                                    curBooking.BookingID,                       // booking_id
                                    "",          // phone_number
                                    toEmail,     // email_to_address
                                    "",          // email_to_name
                                    from_email,  // email_from_address
                                    site.Name,   // email_from_name
                                    text,        // text
                                    subject,     // email_subject
                                    "",    // email_attachment_location
                                    false, // email_attachment_delete_after_sending
                                    false, // email_attachment_folder_delete_after_sending

                                    filesList[0].EmailLetterLetterID,
                                    filesList[0].EmailLetterKeepHistoryInDb,
                                    filesList[0].EmailLetterKeepHistoryInFile,
                                    filesList[0].EmailLetterLetterPrintHistorySendMethodID,
                                    filesList[0].EmailLetterHistoryDir,
                                    filesList[0].EmailLetterHistoryFilename,
                                    filesList[0].EmailLetterSiteID,
                                    filesList[0].EmailLetterOrganisationID,
                                    filesList[0].EmailLetterBookingID,
                                    filesList[0].EmailLetterPatientID,
                                    filesList[0].EmailLetterRegisterReferrerIdToUseInsteadOfPatientsRegRef,
                                    filesList[0].EmailLetterStaffID,
                                    filesList[0].EmailLetterHealthCardActionID,
                                    filesList[0].EmailLetterSourceTemplatePath,
                                    filesList[0].EmailLetterOutputDocPath,
                                    false, // filesList[0].EmailLetterIsDoubleSidedPrinting,
                                    filesList[0].EmailLetterExtraPages,
                                    filesList[0].EmailLetterItemSeperator,

                                    "",    // sql_to_run_on_completion
                                    ""     // sql_to_run_on_failure
                                );

                                for (int f = 1; f < filesList.Length; f++)
                                {
                                    BulkLetterSendingQueueAdditionalLetterDB.Insert(
                                        bulk_letter_sending_queue_id,
                                        filesList[f].EmailLetterLetterID,
                                        filesList[f].EmailLetterKeepHistoryInDb,
                                        filesList[f].EmailLetterKeepHistoryInFile,
                                        filesList[f].EmailLetterLetterPrintHistorySendMethodID,
                                        filesList[f].EmailLetterHistoryDir,
                                        filesList[f].EmailLetterHistoryFilename,
                                        filesList[f].EmailLetterSiteID,
                                        filesList[f].EmailLetterOrganisationID,
                                        filesList[f].EmailLetterBookingID,
                                        filesList[f].EmailLetterPatientID,
                                        filesList[f].EmailLetterRegisterReferrerIdToUseInsteadOfPatientsRegRef,
                                        filesList[f].EmailLetterStaffID,
                                        filesList[f].EmailLetterHealthCardActionID,
                                        filesList[f].EmailLetterSourceTemplatePath,
                                        filesList[f].EmailLetterOutputDocPath,
                                        false, // filesList[f].EmailLetterIsDoubleSidedPrinting,
                                        filesList[f].EmailLetterExtraPages,
                                        filesList[f].EmailLetterItemSeperator);
                                }
                            }
                            else
                            {
                                Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.PDF, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, site.SiteID, staffID, sendMethod == SendMethod.Email_To_Referrer ? 2 : 1);

                                Letter.EmailSystemLetter(site.Name, toEmail, fileContentsList,
                                                         "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename),
                                                         "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name);
                            }

                            if (ReferrerEPCLettersSending.LogDebugEmailInfo)
                                Logger.LogQuery( "["+RndPageID+"]" + "A ReferrerEPCLetters_GenerateUnsent -- Email Send Item Done!", false, false, true);
                        }
                    }
                    else
                    {
                        Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.Word, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, site.SiteID, staffID, sendMethod == SendMethod.Email_To_Referrer ? 2 : 1);
                        if (fileContentsList != null && fileContentsList.Length > 0)
                        {
                            filesToPrint.AddRange(fileContentsList);
                        }
                    }

                    BookingDB.UpdateSetGeneratedSystemLetters(curBooking.BookingID, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, true);
                }

                ArrayList toGenerateList = new ArrayList();
                if (curBooking.NeedToGenerateFirstLetter) toGenerateList.Add("First");
                if (curBooking.NeedToGenerateLastLetter) toGenerateList.Add("Last");
                if (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0) toGenerateList.Add("Notes");
                string toGenerate = string.Join(",", (string[])toGenerateList.ToArray(typeof(string)));

                string addEditContactListPage;
                if (Utilities.GetAddressType().ToString() == "Contact")
                    addEditContactListPage = "ContactAusListV2.aspx";
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                    addEditContactListPage = "ContactAusListV2.aspx";
                else
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());

                string allFeatures = "dialogWidth:555px;dialogHeight:350px;center:yes;resizable:no; scroll:no";
                string onclick = "onclick=\"javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + curPR.RegisterReferrer.Organisation.EntityID.ToString() + "', '', '" + allFeatures + "');document.getElementById('" + btnViewListClientID + "').click();return false;\"";
                string hrefUpdateEmail = "<u><a style=\"text-decoration: none\" title=\"Edit\" AlternateText=\"Edit\" " + onclick + " href=\"\">Update Clinic Email / Fax</a></u>";

                debugOutput += @"<tr>
                                    <td style=""white-space:nowrap;"">" + curBooking.Organisation.GetSiteType().ToString() + @"</td>
                                    <td>" + sendMethod + @"</td>
                                    <td style=""white-space:nowrap;"">" + curBooking.BookingID + " &nbsp;&nbsp;&nbsp;[" + curBooking.DateStart.ToString("dd-MM-yyyy") + "&nbsp;&nbsp;&nbsp;" + curBooking.DateStart.ToString("HH:mm") + "-" + curBooking.DateEnd.ToString("HH:mm") + "]" + @"</td>
                                    <td>" + toGenerate + @"</td>
                                    <td>" + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + @"</td>
                                    <td>" + (curRefHasEmail    ? curRefEmail : "") + @"</td>
                                    <td style=""white-space:nowrap;"">" + (curRefFax != null ? curRefFax : "") + @"</td>
                                    <td style=""white-space:nowrap;"">" + hrefUpdateEmail + @"</td>
                                    <td>" + "<a onclick=\"open_new_tab('PatientDetailV2.aspx?type=view&id=" + curPR.Patient.PatientID + "');return false;\" href=\"PatientDetailV2.aspx?type=view&id=" + curPR.Patient.PatientID + "\">" + curPR.Patient.Person.FullnameWithoutMiddlename + @"</a></td>
                                </tr>";
            }

            if (curPR.RegisterReferrer.BatchSendAllPatientsTreatmentNotes)
                regRefIDsToUpdateDateTimeOfLastBatchSend.Add(curPR.RegisterReferrer.RegisterReferrerID);
        }

        RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes((int[])regRefIDsToUpdateDateTimeOfLastBatchSend.ToArray(typeof(int)), DateTime.Now);

        return (Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents));
    }
コード例 #32
0
 /// <summary>
 /// Add a javascript click action on the column
 /// All Properties marked with GridColumnKey will be send to the controller
 /// </summary>
 /// <param name="action">The action called on the click</param>
 /// <param name="method">Post or Get</param>
 /// <param name="isAjaxSubmit">Call by ajax (Asynchrone)</param>
 public GridColumnClickHandlerAttribute(string action, SendMethod method, bool isAjaxSubmit)
 {
     this.Action       = action;
     this.Method       = method;
     this.IsAjaxSubmit = isAjaxSubmit;
 }
コード例 #33
0
    protected static Letter.FileContents[] ProcessReferrersClinicLetters(SendMethod selectedSendMethod, bool viewListOnly, Site site, int staffID, ArrayList bookingsForCurrentReferrer, ref string debugOutput, string btnViewListClientID)
    {
        if (bookingsForCurrentReferrer.Count == 0)
            return new Letter.FileContents[0];

        // to return - only files to print, as emailing will have been completed
        ArrayList filesToPrint = new ArrayList();

        // an email belongs to the regRef.Org ... so one referrer can have multiple.
        // keep in hash to avoid continued lookups.
        Hashtable refEmailHash = new Hashtable();

        ArrayList regRefIDsToUpdateDateTimeOfLastBatchSend = new ArrayList();

        for (int i = 0; i < bookingsForCurrentReferrer.Count; i++)
        {
            Tuple<Booking, PatientReferrer, bool, string, string, HealthCard> curTuple = (Tuple<Booking, PatientReferrer, bool, string, string, HealthCard>)bookingsForCurrentReferrer[i];
            Booking curBooking    = curTuple.Item1;
            PatientReferrer curPR = curTuple.Item2;
            bool curRefHasEmail   = curTuple.Item3;
            string curRefEmail    = curTuple.Item4;
            string curRefFax      = curTuple.Item5;
            HealthCard curHC      = curTuple.Item6;

            bool needToGenerateLetters = curBooking.NeedToGenerateFirstLetter || curBooking.NeedToGenerateLastLetter ||
                                        (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0);
            if (needToGenerateLetters)
            {
                SendMethod sendMethod = (curRefHasEmail && selectedSendMethod == SendMethod.Email_To_Referrer ? SendMethod.Email_To_Referrer : SendMethod.Batch);

                if (!viewListOnly)
                {
                    if (curRefHasEmail && selectedSendMethod == SendMethod.Email_To_Referrer)
                    {
                        Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.PDF, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, site.SiteID, staffID, sendMethod == SendMethod.Email_To_Referrer ? 2 : 1);
                        if (fileContentsList != null && fileContentsList.Length > 0)
                        {
                            if (ReferrerEPCLettersSending.LogDebugEmailInfo)
                                Logger.LogQuery( "["+RndPageID+"]" + "A ReferrerEPCLetters_GenerateUnsent -- Email Send Item Starting [" + curRefEmail + "][" + curBooking.BookingID + "][" + curBooking.Patient.PatientID + "][" + curBooking.Patient.Person.FullnameWithoutMiddlename + "]", false, false, true);

                            if (ReferrerEPCLettersSending.UseAsyncEmailSending)
                                Letter.EmailAsyncSystemLetter(site.Name, curRefEmail, fileContentsList,
                                                         "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename),
                                                         "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name);
                            else
                                Letter.EmailSystemLetter(site.Name, curRefEmail, fileContentsList,
                                                         "Referral/Treatment Note Letters From Mediclinic" + (curPR.Patient == null ? string.Empty : " For " + curPR.Patient.Person.FullnameWithoutMiddlename),
                                                         "Dr. " + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + "<br /><br />Please find attached referral/treatment note letters for your referrered patient" + (curPR.Patient == null ? string.Empty : " <b>" + curPR.Patient.Person.FullnameWithoutMiddlename + "</b>") + "<br /><br />Best regards,<br />" + site.Name);

                            if (ReferrerEPCLettersSending.LogDebugEmailInfo)
                                Logger.LogQuery( "["+RndPageID+"]" + "A ReferrerEPCLetters_GenerateUnsent -- Email Send Item Done!", false, false, true);
                        }
                    }
                    else
                    {
                        Letter.FileContents[] fileContentsList = curBooking.GetSystemLettersList(Letter.FileFormat.Word, curBooking.Patient, curHC, curBooking.Offering.Field.ID, curPR.RegisterReferrer.Referrer, true, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, curPR.RegisterReferrer.ReportEveryVisitToReferrer, false, site.SiteID, staffID, sendMethod == SendMethod.Email_To_Referrer ? 2 : 1);
                        if (fileContentsList != null && fileContentsList.Length > 0)
                        {
                            filesToPrint.AddRange(fileContentsList);
                        }
                    }

                    BookingDB.UpdateSetGeneratedSystemLetters(curBooking.BookingID, curBooking.NeedToGenerateFirstLetter, curBooking.NeedToGenerateLastLetter, true);
                }

                ArrayList toGenerateList = new ArrayList();
                if (curBooking.NeedToGenerateFirstLetter) toGenerateList.Add("First");
                if (curBooking.NeedToGenerateLastLetter) toGenerateList.Add("Last");
                if (curPR.RegisterReferrer.ReportEveryVisitToReferrer && curBooking.NoteCount > 0) toGenerateList.Add("Notes");
                string toGenerate = string.Join(",", (string[])toGenerateList.ToArray(typeof(string)));

                string addEditContactListPage;
                if (Utilities.GetAddressType().ToString() == "Contact")
                    addEditContactListPage = "ContactAusListV2.aspx";
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                    addEditContactListPage = "ContactAusListV2.aspx";
                else
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());

                string allFeatures = "dialogWidth:555px;dialogHeight:350px;center:yes;resizable:no; scroll:no";
                string onclick = "onclick=\"javascript:window.showModalDialog('" + addEditContactListPage + "?entity_type=referrer&id=" + curPR.RegisterReferrer.Organisation.EntityID.ToString() + "', '', '" + allFeatures + "');document.getElementById('" + btnViewListClientID + "').click();return false;\"";
                string hrefUpdateEmail = "<u><a style=\"text-decoration: none\" title=\"Edit\" AlternateText=\"Edit\" " + onclick + " href=\"\">Update Clinic Email / Fax</a></u>";

                debugOutput += @"<tr>
                                    <td style=""white-space:nowrap;"">" + curBooking.Organisation.GetSiteType().ToString() + @"</td>
                                    <td>" + sendMethod + @"</td>
                                    <td style=""white-space:nowrap;"">" + curBooking.BookingID + " &nbsp;&nbsp;&nbsp;[" + curBooking.DateStart.ToString("dd-MM-yyyy") + "&nbsp;&nbsp;&nbsp;" + curBooking.DateStart.ToString("HH:mm") + "-" + curBooking.DateEnd.ToString("HH:mm") + "]" + @"</td>
                                    <td>" + toGenerate + @"</td>
                                    <td>" + curPR.RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename + @"</td>
                                    <td>" + (curRefHasEmail    ? curRefEmail : "") + @"</td>
                                    <td style=""white-space:nowrap;"">" + (curRefFax != null ? curRefFax : "") + @"</td>
                                    <td style=""white-space:nowrap;"">" + hrefUpdateEmail + @"</td>
                                    <td>" + curPR.Patient.Person.FullnameWithoutMiddlename + @"</td>
                                </tr>";
            }

            if (curPR.RegisterReferrer.BatchSendAllPatientsTreatmentNotes)
                regRefIDsToUpdateDateTimeOfLastBatchSend.Add(curPR.RegisterReferrer.RegisterReferrerID);
        }

        RegisterReferrerDB.UpdateLastBatchSendAllPatientsTreatmentNotes((int[])regRefIDsToUpdateDateTimeOfLastBatchSend.ToArray(typeof(int)), DateTime.Now);

        return (Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents));
    }
コード例 #34
0
 /// <summary>
 /// Add a javascript click action on the column
 /// All Properties marked with GridColumnKey will be send to the controller
 /// </summary>
 /// <param name="action">The action called on the click</param>
 /// <param name="method">Post or Get</param>
 /// <param name="isAjaxSubmit">Call by ajax (Asynchrone)</param>
 /// <param name="gridAction">Call an action on the grid if the server response is OK</param>
 public GridColumnClickHandlerAttribute(string action, SendMethod method, bool isAjaxSubmit, OnSuccessGridAction gridAction)
     : this(action, method, isAjaxSubmit)
 {
     this.GridAction = gridAction;
 }
コード例 #35
0
ファイル: Packet.cs プロジェクト: FaNtA91/pokemonapi
        public bool Send(SendMethod method)
        {
            if (msg == null)
                msg = new NetworkMessage(Client, 4048);

            switch (method)
            {

                case SendMethod.Proxy:
                    lock (msgLock)
                    {
                        msg.Reset();
                        ToNetworkMessage(msg);

                        if (msg.Length > 8)
                        {
                            msg.InsetLogicalPacketHeader();
                            msg.PrepareToSend();

                            if (Destination == PacketDestination.Client)
                                Client.IO.Proxy.SendToClient(msg.GetData());
                            else if (Destination == PacketDestination.Server)
                                Client.IO.Proxy.SendToServer(msg.GetData());

                            return true;
                        }
                    }
                    break;
                case SendMethod.HookProxy:
                    lock (msgLock)
                    {
                        msg.Reset();
                        ToNetworkMessage(msg);

                        if (msg.Length > 8)
                        {
                            msg.InsetLogicalPacketHeader();
                            msg.PrepareToSend();

                            Pipes.HookSendToServerPacket.Send(Client, msg.GetData());

                            return true;
                        }
                    }
                    break;
                case SendMethod.Memory:
                    lock (msgLock)
                    {
                        msg.Reset();
                        ToNetworkMessage(msg);
                        if (Destination == PacketDestination.Server)
                        {
                            if (msg.Length > 8)
                            {
                                msg.InsetLogicalPacketHeader();
                                msg.PrepareToSend();

                                return SendPacketToServerByMemory(Client, msg.GetData());
                            }
                        }
                        else if (Destination == PacketDestination.Client)
                        {
                            byte[] data = new byte[msg.GetData().Length - 8];
                            Array.Copy(msg.GetData(), 8, data, 0, data.Length);
                            SendPacketToClientByMemory(Client, data);
                        }
                    }
                    break;
            }

            return false;
        }
コード例 #36
0
 /// <summary>
 /// Add a javascript click action on the column
 /// All Properties marked with GridColumnKey will be send to the controller
 /// This call is not asynchrone (don't use Ajax)
 /// </summary>
 /// <param name="action">The action called on the click</param>
 /// <param name="method">Post or Get</param>
 public GridColumnClickHandlerAttribute(string action, SendMethod method)
     : this(action, method, false)
 {
 }
コード例 #37
0
    public static Letter.FileContents Run(SendMethod sendMethod, int siteID, int staffID, int registerReferrerID, bool incBatching, bool incUnsent, bool incWithEmailOrFaxOnly, bool viewListOnly, bool viewFullList, out string outputInfo, out string outputList, string btnViewListClientID)
    {
        int bulkLetterSendingQueueBatchID = !viewListOnly && UseBulkLetterSender ? BulkLetterSendingQueueBatchDB.Insert(DebugEmail, false) : -1;

        RndPageID = (new Random()).Next().ToString();

        bool debugMode = true;

        bool AutoSendFaxesAsEmailsIfNoEmailExistsToGPs = Convert.ToInt32(SystemVariableDB.GetByDescr("AutoSendFaxesAsEmailsIfNoEmailExistsToGPs").Value) == 1;

        string tmpLettersDirectory = Letter.GetTempLettersDirectory();
        if (!Directory.Exists(tmpLettersDirectory))
            throw new CustomMessageException("Temp letters directory doesn't exist");

        int    startTime = 0;
        double queryExecutionTimeClinic                  = 0;
        double generateFilesToPrintExecutionTimeClinic   = 0;
        double queryExecutionTimeAgedCare                = 0;
        double generateFilesToPrintExecutionTimeAgedCare = 0;

        outputInfo = string.Empty;
        outputList = string.Empty;

        //
        //  We can not send email all their patients in one email - will be too big with attachments and rejected by their mail provider
        //  So if via email - need to send one at a time
        //  Then if cuts out or times out, it has processed some so don't need to re-process those when it's run again
        //
        //  remember to process the emails first ... so if any interruptions/errors ... at least some will have been processed
        //

        Site[] allSites    = SiteDB.GetAll();
        bool   runAllSites = siteID == -1;

        Site   agedCareSite = null;
        Site   clinicSite   = null;
        Site[] sitesToRun   = runAllSites ? allSites : new Site[] { SiteDB.GetByID(siteID) };
        foreach (Site s in sitesToRun)
        {
            if (s.SiteType.ID == 1)
                clinicSite   = s;
            else if (s.SiteType.ID == 2)
                agedCareSite = s;
        }

        Hashtable orgHash = OrganisationDB.GetAllHashtable(true, true, false, false, true, true);

        ArrayList filesToPrintClinic   = new ArrayList();
        ArrayList filesToPrintAgedCare = new ArrayList();
        string debugOutput = string.Empty;
        int numGenerated = 0;

        DataTable bookingsWithUnsetnLettersClinic   = null;
        DataTable bookingsWithUnsetnLettersAgedCare = null;

        if (clinicSite != null)
        {

            startTime = Environment.TickCount;

            bookingsWithUnsetnLettersClinic = BookingDB.GetBookingsWithEPCLetters(DateTime.MinValue, DateTime.MinValue, registerReferrerID, -1, false, true, incBatching, incUnsent);

            queryExecutionTimeClinic = (double)(Environment.TickCount - startTime) / 1000.0;
            startTime = Environment.TickCount;

            int currentRegReferrerID = -1;
            ArrayList bookingsForCurrentReferrer = new ArrayList();
            Hashtable rowIDsToRemove = new Hashtable();
            foreach (DataRow row in bookingsWithUnsetnLettersClinic.Rows)
            {
                numGenerated++;

                //if (numGenerated % 15 != 1) continue;
                if ((!viewListOnly || !viewFullList) && (numGenerated > MaxSending))
                    continue;

                Tuple<Booking, PatientReferrer, bool, bool, string, string, HealthCard> rowData = LoadClinicRow(row);

                // realod org to get full org data (in particular, org type to get site-type
                if (orgHash[rowData.Item1.Organisation.OrganisationID] != null)
                    rowData.Item1.Organisation = (Organisation)orgHash[rowData.Item1.Organisation.OrganisationID];

                Booking         booking     = rowData.Item1;
                PatientReferrer pr          = rowData.Item2;
                bool            refHasEmail = rowData.Item3;
                bool            refHasFax   = rowData.Item4;
                string          refEmail    = rowData.Item5;
                string          refFax      = rowData.Item6;
                HealthCard      hc          = rowData.Item7;

                bool refHasEmailOrFax = AutoSendFaxesAsEmailsIfNoEmailExistsToGPs ? (refHasEmail || refHasFax) : refHasEmail;
                if (incWithEmailOrFaxOnly && !refHasEmailOrFax)
                {
                    numGenerated--;
                    rowIDsToRemove[booking.BookingID] = 1;
                    continue;
                }

                //if (booking.Patient == null || (booking.Patient.PatientID != 31522 && booking.Patient.PatientID != 27654))
                //{
                //    numGenerated--;
                //    continue;
                //}

                if (pr.RegisterReferrer.RegisterReferrerID != currentRegReferrerID)
                {
                    filesToPrintClinic.AddRange(ProcessReferrersClinicLetters(sendMethod, viewListOnly, allSites, staffID, bookingsForCurrentReferrer, AutoSendFaxesAsEmailsIfNoEmailExistsToGPs, ref debugOutput, btnViewListClientID, bulkLetterSendingQueueBatchID));
                    currentRegReferrerID = pr.RegisterReferrer.RegisterReferrerID;
                    bookingsForCurrentReferrer = new ArrayList();
                }

                bookingsForCurrentReferrer.Add(rowData);
            }

            if (bookingsWithUnsetnLettersClinic.Rows.Count > 0)
                for (int i = bookingsWithUnsetnLettersClinic.Rows.Count - 1; i >= 0; i--)
                    if (rowIDsToRemove[Convert.ToInt32(bookingsWithUnsetnLettersClinic.Rows[i]["booking_booking_id"])] != null)
                        bookingsWithUnsetnLettersClinic.Rows.RemoveAt(i);

            // process last group
            filesToPrintClinic.AddRange(ProcessReferrersClinicLetters(sendMethod, viewListOnly, allSites, staffID, bookingsForCurrentReferrer, AutoSendFaxesAsEmailsIfNoEmailExistsToGPs, ref debugOutput, btnViewListClientID, bulkLetterSendingQueueBatchID));

            generateFilesToPrintExecutionTimeClinic = (double)(Environment.TickCount - startTime) / 1000.0;

        }
        if (agedCareSite != null)
        {

            startTime = Environment.TickCount;

            bookingsWithUnsetnLettersAgedCare = BookingPatientDB.GetBookingsPatientOfferingsWithEPCLetters(DateTime.MinValue, DateTime.MinValue, registerReferrerID, -1, false, true, incBatching, incUnsent);

            queryExecutionTimeAgedCare = (double)(Environment.TickCount - startTime) / 1000.0;
            startTime = Environment.TickCount;

            int currentRegReferrerID = -1;
            ArrayList bookingsForCurrentReferrer = new ArrayList();
            Hashtable rowIDsToRemove = new Hashtable();
            foreach (DataRow row in bookingsWithUnsetnLettersAgedCare.Rows)
            {
                numGenerated++;
                //if (numGenerated % 15 != 1) continue;
                if ((!viewListOnly || !viewFullList) && (numGenerated > MaxSending))
                    continue;
                Tuple<BookingPatient, Offering, PatientReferrer, bool, bool, string, string, Tuple<HealthCard>> rowData = LoadAgedCareRow(row);

                // realod org to get full org data (in particular, org type to get site-type
                if (orgHash[rowData.Item1.Booking.Organisation.OrganisationID] != null)
                    rowData.Item1.Booking.Organisation = (Organisation)orgHash[rowData.Item1.Booking.Organisation.OrganisationID];

                BookingPatient  bp          = rowData.Item1;
                Offering        offering    = rowData.Item2;
                PatientReferrer pr          = rowData.Item3;
                bool            refHasEmail = rowData.Item4;
                bool            refHasFax   = rowData.Item5;
                string          refEmail    = rowData.Item6;
                string          refFax      = rowData.Item7;
                HealthCard      hc          = rowData.Rest.Item1;

                bool refHasEmailOrFax = AutoSendFaxesAsEmailsIfNoEmailExistsToGPs ? (refHasEmail || refHasFax) : refHasEmail;
                if (incWithEmailOrFaxOnly && !refHasEmailOrFax)
                {
                    numGenerated--;
                    rowIDsToRemove[bp.BookingPatientID] = 1;
                    continue;
                }

                //if (bp.Booking.Patient == null || (bp.Booking.Patient.PatientID != 31522 && bp.Booking.Patient.PatientID != 27654))
                //{
                //    numGenerated--;
                //    continue;
                //}

                if (pr.RegisterReferrer.RegisterReferrerID != currentRegReferrerID)
                {
                    filesToPrintAgedCare.AddRange(ProcessReferrersAgedCareLetters(sendMethod, viewListOnly, allSites, staffID, bookingsForCurrentReferrer, AutoSendFaxesAsEmailsIfNoEmailExistsToGPs, ref debugOutput, btnViewListClientID, bulkLetterSendingQueueBatchID));
                    currentRegReferrerID = pr.RegisterReferrer.RegisterReferrerID;
                    bookingsForCurrentReferrer = new ArrayList();
                }

                bookingsForCurrentReferrer.Add(rowData);
            }

            if (bookingsWithUnsetnLettersAgedCare.Rows.Count > 0)
                for (int i = bookingsWithUnsetnLettersAgedCare.Rows.Count - 1; i >= 0; i--)
                    if (rowIDsToRemove[Convert.ToInt32(bookingsWithUnsetnLettersAgedCare.Rows[i]["bp_booking_patient_id"])] != null)
                        bookingsWithUnsetnLettersAgedCare.Rows.RemoveAt(i);

            // process last group
            filesToPrintAgedCare.AddRange(ProcessReferrersAgedCareLetters(sendMethod, viewListOnly, allSites, staffID, bookingsForCurrentReferrer, AutoSendFaxesAsEmailsIfNoEmailExistsToGPs, ref debugOutput, btnViewListClientID, bulkLetterSendingQueueBatchID));

            generateFilesToPrintExecutionTimeAgedCare = (double)(Environment.TickCount - startTime) / 1000.0;

        }

        startTime = Environment.TickCount;

        bool zipSeperately = true;
        Letter.FileContents zipFileContents = null;

        if (zipSeperately && (filesToPrintClinic.Count + filesToPrintAgedCare.Count) > 0)
        {

            // if 2 sites exist in the system - change doc names to have "[AgedCare]" or "[Clinics]" before docname
            if (allSites.Length > 1)
            {
                for (int i = 0; i < filesToPrintClinic.Count; i++)
                    ((Letter.FileContents)filesToPrintClinic[i]).DocName = "[Clinics] " + ((Letter.FileContents)filesToPrintClinic[i]).DocName;
                for (int i = 0; i < filesToPrintAgedCare.Count; i++)
                    ((Letter.FileContents)filesToPrintAgedCare[i]).DocName = "[AgedCare] " + ((Letter.FileContents)filesToPrintAgedCare[i]).DocName;
            }

            ArrayList filesToPrint = new ArrayList();
            filesToPrint.AddRange(filesToPrintClinic);
            filesToPrint.AddRange(filesToPrintAgedCare);

            // seperate into doc types because can only merge docs with docs of same template (ie docname)
            Hashtable filesToPrintHash = new Hashtable();
            for (int i = 0; i < filesToPrint.Count; i++)
            {
                Letter.FileContents curFileContents = (Letter.FileContents)filesToPrint[i];
                if (filesToPrintHash[curFileContents.DocName] == null)
                    filesToPrintHash[curFileContents.DocName] = new ArrayList();
                ((ArrayList)filesToPrintHash[curFileContents.DocName]).Add(curFileContents);
            }

            // merge and put merged files into temp dir
            string baseTmpDir = FileHelper.GetTempDirectoryName(tmpLettersDirectory);
            string tmpDir = baseTmpDir + "Referral Letters" + @"\";
            Directory.CreateDirectory(tmpDir);
            string[] tmpFiles = new string[filesToPrintHash.Keys.Count];
            IDictionaryEnumerator enumerator = filesToPrintHash.GetEnumerator();
            for (int i = 0; enumerator.MoveNext(); i++)
            {
                ArrayList files = (ArrayList)enumerator.Value;
                string docName = (string)enumerator.Key;

                // last file is screwing up, so just re-add the last file again for a temp fix
                files.Add(files[files.Count - 1]);

                Letter.FileContents fileContents = Letter.FileContents.Merge((Letter.FileContents[])files.ToArray(typeof(Letter.FileContents)), docName); // .pdf

                string tmpFileName = tmpDir + fileContents.DocName;
                System.IO.File.WriteAllBytes(tmpFileName, fileContents.Contents);
                tmpFiles[i] = tmpFileName;
            }

            // zip em
            string zipFileName = "Referral Letters.zip";
            string zipFilePath = baseTmpDir + zipFileName;
            ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
            zip.CreateEmptyDirectories = true;
            zip.CreateZip(zipFilePath, tmpDir, true, "");

            // get filecontents of zip here
            zipFileContents = new Letter.FileContents(zipFilePath, zipFileName);
            //Letter.FileContents zipFileContents = new Letter.FileContents(zipFilePath, zipFileName);
            //System.Web.HttpContext.Current.Session["downloadFile_Contents"] = zipFileContents.Contents;
            //System.Web.HttpContext.Current.Session["downloadFile_DocName"]  = zipFileContents.DocName;

            // delete files
            for (int i = 0; i < tmpFiles.Length; i++)
            {
                System.IO.File.SetAttributes(tmpFiles[i], FileAttributes.Normal);
                System.IO.File.Delete(tmpFiles[i]);
            }
            System.IO.File.SetAttributes(zipFilePath, FileAttributes.Normal);
            System.IO.File.Delete(zipFilePath);
            System.IO.Directory.Delete(tmpDir, false);
            System.IO.Directory.Delete(baseTmpDir, false);

            // put in session variables so when it reloads to this page, we can popup the download window
            //Page.ClientScript.RegisterStartupScript(this.GetType(), "download", "<script language=javascript>window.open('DownloadFile.aspx','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=30,height=30');</script>");
        }

        if (!zipSeperately && (filesToPrintClinic.Count + filesToPrintAgedCare.Count) > 0)
        {
            ArrayList filesToPrint = new ArrayList();
            filesToPrint.AddRange(filesToPrintClinic);
            filesToPrint.AddRange(filesToPrintAgedCare);

            zipFileContents = Letter.FileContents.Merge((Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents)), "Referral Letters.doc"); // .pdf
            //Letter.FileContents fileContents = Letter.FileContents.Merge((Letter.FileContents[])filesToPrint.ToArray(typeof(Letter.FileContents)), "Referral Letters.doc"); // .pdf
            //System.Web.HttpContext.Current.Session["downloadFile_Contents"] = fileContents.Contents;
            //System.Web.HttpContext.Current.Session["downloadFile_DocName"]  = fileContents.DocName;

            // put in session variables so when it reloads to this page, we can popup the download window
            //Page.ClientScript.RegisterStartupScript(this.GetType(), "download", "<script language=javascript>window.open('DownloadFile.aspx','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=30,height=30');</script>");
        }

        if (!viewListOnly && registerReferrerID == -1 && incBatching)
            SetLastDateBatchSendTreatmentNotesAllReferrers(DateTime.Now);

        double restExecutionTime = (double)(Environment.TickCount - startTime) / 1000.0;

        if (debugMode)
        {
            int total = (bookingsWithUnsetnLettersClinic == null ? 0 : bookingsWithUnsetnLettersClinic.Rows.Count) + (bookingsWithUnsetnLettersAgedCare == null ? 0 : bookingsWithUnsetnLettersAgedCare.Rows.Count);
            string countGenrated = total > MaxSending ? MaxSending + " of " + total + " generated" : total.ToString() + " generated";
            string countShowing = total > MaxSending ? MaxSending + " of " + total + " showing to generate. <br />* If there are more than " + MaxSending + ", the next " + MaxSending + " will have to be generated seperately after this." : total.ToString();
            if (total > MaxSending && viewFullList)
                countShowing = total + " showing to generate. <br />* If there are more than " + MaxSending + ", only the first " + MaxSending + " will be generated and batches of " + MaxSending + " will have to be generated seperately after.";

            string queryExecutionTimeText = string.Empty;
            if (agedCareSite == null && clinicSite == null)
                queryExecutionTimeText = "0";
            if (agedCareSite == null && clinicSite != null)
                queryExecutionTimeText = queryExecutionTimeClinic.ToString();
            if (agedCareSite != null && clinicSite == null)
                queryExecutionTimeText = queryExecutionTimeAgedCare.ToString();
            if (agedCareSite != null && clinicSite != null)
                queryExecutionTimeText = "[Clinics: " + queryExecutionTimeClinic + "] [AgedCare: " + queryExecutionTimeAgedCare + "]";

            string restExecutionTimeText = string.Empty;
            if (agedCareSite == null && clinicSite == null)
                restExecutionTimeText = "0";
            if (agedCareSite == null && clinicSite != null)
                restExecutionTimeText = (generateFilesToPrintExecutionTimeClinic + restExecutionTime).ToString();
            if (agedCareSite != null && clinicSite == null)
                restExecutionTimeText = (generateFilesToPrintExecutionTimeAgedCare + restExecutionTime).ToString();
            if (agedCareSite != null && clinicSite != null)
                restExecutionTimeText = "[Clinics: " + generateFilesToPrintExecutionTimeClinic + "] [AgedCare: " + generateFilesToPrintExecutionTimeAgedCare + "] [Merging" + restExecutionTime + "]";

            if (!viewListOnly)
                outputInfo = @"<table cellpadding=""0"">
                                <tr><td><b>Send Method</b></td><td style=""width:10px;""></td><td>" + sendMethod.ToString() + @"</td><td style=""width:25px;""></td><td><b>Query Time</b></td><td style=""width:10px;""></td><td>" + queryExecutionTimeText + @" seconds</td></tr>
                                <tr><td><b>Count</b></td><td style=""width:10px;""></td><td>" + countGenrated + @"</td><td style=""width:25px;""></td><td><b>Runing Time</b></td><td style=""width:10px;""></td><td>" + restExecutionTimeText + @" seconds</td></tr>
                                </table>";

            if (viewListOnly)
                outputInfo = @"<table cellpadding=""0"">
                                <tr><td valign=""top""><b>Count</b></td><td style=""width:10px;""></td><td>" + countShowing + @"</td></tr>
                                </table>";

            if (viewListOnly)
                outputList = @"<table class=""table table-bordered table-striped table-grid table-grid-top-bottum-padding-thick auto_width block_center"" border=""1"">
                                    <tr>
                                        <th>Site</th>
                                        <th>Send By</th>
                                        <th>Booking</th>
                                        <th>Generate</th>
                                        <th>Referrer</th>
                                        <th>Email</th>
                                        <th>Fax</th>
                                        <th>Update Email/Fax</th>
                                        <th>Patient</th>
                                    </tr>" +
                                    (debugOutput.Length == 0 ? "<tr><td colspan=\"9\">No Rows</td></tr>" : debugOutput) +
                                "</table>";
        }

        if (UseBulkLetterSender)
            BulkLetterSendingQueueBatchDB.UpdateReadyToProcess(bulkLetterSendingQueueBatchID, true);

        return zipFileContents;
    }
コード例 #38
0
 public override bool Write(Identity target, byte[] data, ulong length, SendMethod method, int channel)
 {
     LogUtils.Debug("Writing with method: " + method + " in channel " + channel);
     return(SteamNetworking.SendP2PPacket((CSteamID)(SteamIdentity)target, data, (uint)length, (EP2PSend)method, channel));
 }
コード例 #39
0
 private HttpResponse InternalSendRequest(SendMethod sendMethod, params object[] objects)
 {
     Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     if (!ConnectSocket(s)) return cannotConnectResponse;
     try
     {
         sendMethod(s, objects);
         s.Shutdown(SocketShutdown.Send);
         return ReceiveResponse(s);
     }
     catch (SocketException e)
     {
         return new HttpResponse(500, Encoding.UTF8.GetBytes(e.ToString()));
     }
     finally { s.Close(); }
 }