Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Asterisk.NET.FastAGI;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Goldnet.IVR.ResellerPanelService;
- using Goldnet.IVR.ServiceReference1;
- using Goldnet.Crm.Data;
- using System.Configuration;
- using Asterisk.NET.Manager;
- using Asterisk.NET.Manager.Action;
- using Asterisk.NET.Manager.Response;
- using System.Xml.Linq;
- using System.Timers;
- using System.Threading;
- using System.Data.Entity.Validation;
- using System.Diagnostics;
- using Asterisk.NET.Manager.Event;
- using System.Net;
- using System.IO;
- using System.Data.Entity.SqlServer;
- namespace Goldnet.IVR
- {
- public class GoldnetDemo : AGIScript
- {
- public static string ResellerId = "";
- public static string callerId = "1";
- public override void Service(AGIRequest request, AGIChannel channel)
- {
- Console.WriteLine("test : " + request);
- #region Variables
- var db = new GoldnetEntities();
- int maxLine = 0;
- Boolean QueueIsFull = false;
- int priority = 0;
- string QuOption = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSayAgentName"]) ? ",,,,queue.py" : "";
- char key = ' ';
- int counterPlaySound = 0;
- bool rpeatSound = true;
- bool MainIvr = false;
- string SipName = "";
- string TariffName = "";
- double timeout = Convert.ToDouble(ConfigurationManager.AppSettings["ResellerService.TimeOut"]);
- string CardNumber = ConfigurationManager.AppSettings["CardNumber"];
- var identifier = request.UniqueId;
- var data = "";
- string ChargResult = "0";
- int InsertId = 0;
- int smsresult = -1;
- var ivrc = new IVRServices.ServiceClient();
- string ServiceId = "", mobileNumber = "";
- string serviceName = "3 گیگ ترافیک مازاد";
- long PriceLong = 0;
- bool RepeatMainMenu = false;
- var Payic = new SimulateParsianPaymentService.PaymentServiceSoapClient();
- if (!string.IsNullOrEmpty(request.CallerId))
- callerId = request.CallerId;
- Console.WriteLine("callerId : " + callerId);
- //PriceLong = 120000;
- //if (callerId == "09360769982")
- //{
- // callerId = "5136634861";
- // PriceLong = 10000;
- //}
- #endregion
- if (callerId.StartsWith("0"))
- callerId = callerId.TrimStart("0".ToCharArray());
- if (callerId.Length > 10)
- callerId = callerId.Substring(callerId.Length - 10, 10);
- IvrCallState callState = null;
- try
- {
- callState = db.IvrCallStates.FirstOrDefault(p => p.callId == request.UniqueId);
- }
- catch (Exception ex)
- {
- this.log(identifier, IvrLogTypes.Error, ex.Message);
- }
- //مدیریت تماس خروجی
- var Sipresult = db.IvrSipFriends.Where(o => o.name == request.CallerId || o.name == request.Extension).FirstOrDefault();
- if (Sipresult != null)
- {
- //در صورتی که تماس از داخل باشد. مثلا 300 به *01 زنگ بزند
- if (request.Extension.Substring(0, 1) == "*")
- {
- IvrDialPlan ivrDialPlan1 = null;
- string DialNumber = "";
- ivrDialPlan1 = db.IvrDialPlans.FirstOrDefault(p => p.Title == "StarIVR" && p.ParentId == 0 && p.KeyOfDialPlan == request.Extension);
- if (ivrDialPlan1 != null)
- {
- DialNumber = ivrDialPlan1.ValueOfKey;
- //ترانک خروجی که از جدول میخونه مثلا
- //cisco/#8809155019953
- Exec("Dial", "SIP/" + DialNumber + ",45,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- }
- }
- //در صورتی که تماس از داخل باشد. به بیرون از شرکت ، با داخلی 9 برای تماس بیرون
- if (request.Extension.Substring(0, 1) == "9" && request.Extension.Length > 3)
- {
- //تیم شبکه باید درست کنه این رو. ترانک خروجی
- //cisco/#8809155019953
- Exec("Dial", "SIP/cisco/#88" + request.Extension.Substring(1, request.Extension.Length - 1) + ",45,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- }
- else
- {
- //برای تماسی که از بیرون می آید و صف هم دارد ، مثلا 14 صف دارد
- //صف برای بعضی از شماره ها ، نیستانی ، سعادتمند
- callState.AgentId = request.Extension; // just for GoldnetIvr because there is no queue
- db.SaveChanges();
- var QueueOfSip = db.IvrQueueMembers.Where(o => o.membername == request.Extension).Select(o => o.queue_name).FirstOrDefault();
- if (QueueOfSip != null)
- {
- maxLine = db.IvrQueues.Where(o => o.name == QueueOfSip).Select(o => o.queue_member_count).FirstOrDefault();
- var InQueueCount = db.IvrCallStates.Where(p => (new string[] { "RINGNOANSWER", "ENTERQUEUE" }).Contains(p.status) && p.cdrid == null && p.queue == QueueOfSip && SqlFunctions.DateDiff("mi", p.timestamp, DateTime.Now) < 60).Count();
- if (maxLine <= InQueueCount)
- {
- callState.status = "QueueIsFull";
- QueueIsFull = true;
- StreamFile("fa_BusySip");
- StreamFile("fa_PleaseCallAgain");
- }
- else
- {
- bool q = this.queue(QueueOfSip, identifier, priority, false, QuOption);
- }
- }
- else
- {
- //برای تماسی که از بیرون می آید و صف هم نداریم ، مثلا 300 صف ندارد
- string dialledNum = "";
- dialledNum = request.Extension;
- Console.Write("Dial + SIP/" + dialledNum + ",45,tr");
- Exec("Dial", "SIP/" + dialledNum + ",45,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- if (dialstatus == "CHANUNAVAIL" && dialstatus == "BUSY")
- {
- StreamFile("fa_BusySip");
- StreamFile("fa_PleaseCallAgain");
- //go to 14 !
- //Exec("Dial", "SIP/14,45,tr");
- }
- if (dialstatus == "NOANSWER")
- {
- StreamFile("fa_NoAnswerSip");
- StreamFile("fa_PleaseCallAgain");
- }
- }
- }
- }
- else
- {
- //اگر تماس از بیرون داشتیم ، توی این قسمت می رود
- //LoadConfigConnection();
- #region Answer
- try
- {
- Answer();
- this.log(identifier, IvrLogTypes.Answer, request.CallerId);
- }
- catch (Exception ex)
- {
- this.log(identifier, IvrLogTypes.Error, ex.ToString());
- if (ex.ToString().Contains("Channel was hung up"))
- {
- callState.Comment = "Channel was hung up";
- callState.status = "HangUp";
- db.SaveChanges();
- return;
- }
- }
- #endregion
- #region comment1
- //try
- //{
- // Thread t = new Thread(DoSomething);
- // t.Start();
- // if (!t.Join(TimeSpan.FromSeconds(timeout)))
- // {
- // t.Abort();
- // Console.WriteLine("CallerId For Test :" + callerId + " ResellerId : " + ResellerId);
- // }
- //}
- //catch (Exception ex)
- //{
- // this.log(identifier, IvrLogTypes.Developer, ex.Message);
- //}
- //// ResellerId = "99999";
- //Console.WriteLine("RessellerId : " + ResellerId);
- //if (ResellerId != "" && ResellerId != null)
- //{
- // #region Reseller
- // try
- // {
- // data = GetData("fa_welcomes", 500, 3);
- // while (counterPlaySound < 3 && rpeatSound)
- // {
- // data = GetData("fa_EnterTel", 5000, 10);
- // Console.WriteLine("CustomerTelNumber :::: " + data);
- // counterPlaySound++;
- // if (data.Length == 10)
- // {
- // string CustomerTelNumber = "";
- // CustomerTelNumber = data;
- // data = GetData("fa_TelNumberIs", 5000, 1);
- // for (int i = 0; i < CustomerTelNumber.Length; i = i + 2)
- // {
- // string number = CustomerTelNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_IsAcceptTelNumber", 5000, 10);
- // if (data == "1")
- // {
- // rpeatSound = false;
- // Console.WriteLine("CustomerTelNumber :" + CustomerTelNumber);
- // ServiceWrappers.ServiceResponse UserInfo = partner.GetUserInfoViaCustomer(CustomerTelNumber);
- // ServiceWrappers.UserInfo returnObject = (ServiceWrappers.UserInfo)UserInfo.ReturnedObject;
- // if (returnObject != null && returnObject.RemainingTraffic > 0)
- // {
- // data = GetData("fa_Volume", 1000, 1);
- // int reservedTraffic = Convert.ToInt32(returnObject.ReservedTraffic * 1024);
- // Console.WriteLine("reservedTraffic :" + reservedTraffic);
- // int MegTraffic = Convert.ToInt32(returnObject.RemainingTraffic * 1024) + reservedTraffic;
- // string remainingTraffic = MegTraffic.ToString();
- // Console.WriteLine("remainingTraffic :" + remainingTraffic);
- // switch (remainingTraffic.Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, remainingTraffic, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, remainingTraffic, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, remainingTraffic, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, remainingTraffic, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, remainingTraffic, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, remainingTraffic, false);
- // break;
- // default:
- // break;
- // }
- // data = GetData("fa_Meg", 1000, 1);
- // }
- // data = GetData("fa_WantToCharge_Reseller", 5000, 1);
- // if (data == "1") // Customer Want To Charge
- // {
- // data = GetData("fa_Gig", 5000, 1);
- // switch (data)
- // {
- // case "1":
- // TariffName = "1 گیگ ترافیک مازاد";
- // break;
- // case "2":
- // TariffName = "2 گیگ ترافیک مازاد";
- // break;
- // case "3":
- // TariffName = "5 گیگ ترافیک مازاد";
- // break;
- // case "4":
- // TariffName = "10 گیگ ترافیک مازاد";
- // break;
- // default:
- // break;
- // }
- // var chargeResult = partner.ChargeCustomer(CustomerTelNumber, ResellerId, TariffName);
- // IvrResellerCharge qm = new IvrResellerCharge
- // {
- // CustomerTel = CustomerTelNumber,
- // ResellerId = Convert.ToInt32(ResellerId),
- // TrafficName = TariffName,
- // Chargeresult = Convert.ToInt32(chargeResult.Code.ToString()),
- // chargeDate = DateTime.Now
- // };
- // db.IvrResellerCharges.Add(qm);
- // db.SaveChanges();
- // if (chargeResult.Code.ToString() == "1")
- // {
- // Console.WriteLine("Successful Charge" + chargeResult.Code);
- // data = GetData("digits/Successful", 500, 1);
- // Console.WriteLine("Successs in Reseller");
- // //SendSMS();
- // }
- // else
- // {
- // Console.WriteLine("UnSuccessful Charge" + chargeResult.Code);
- // data = GetData("fa_unsuccess", 500, 1);
- // }
- // }
- // }
- // }
- // else if (data == "9")
- // {
- // MainIvr = true;
- // counterPlaySound = 3;
- // }
- // else
- // data = GetData("fa_IncorrectTelNum", 1000, 1);
- // }
- // }
- // catch (Exception ex)
- // {
- // this.log(identifier, IvrLogTypes.Developer, ex.Message);
- // }
- // #endregion
- //}
- //else
- // MainIvr = true;
- #endregion
- MainIvr = true;
- RepeatMainMenu = true;
- int counterCall = 1;
- while (MainIvr && RepeatMainMenu)
- {
- #region Custommer
- try
- {
- bool CustomerCharge = false;
- Console.WriteLine("In Main Ivr");
- data = GetData("fa_MainIVR", 3000, 4);
- string EnteredKey = data;
- IvrDialPlan ivrDialPlan = null;
- RepeatMainMenu = false;
- if (EnteredKey != "")
- {
- ivrDialPlan = db.IvrDialPlans.FirstOrDefault(p => p.Title == "MainIVR" && p.ParentId == 0 && p.KeyOfDialPlan == EnteredKey);
- if (ivrDialPlan != null)
- SipName = ivrDialPlan.ValueOfKey;
- else
- SipName = data;
- string PressKey = "";
- if (SipName == "Commerce")
- {
- data = GetData("fa_CommerceMenu", 3000, 1);
- PressKey = data;
- }
- if (SipName == "Support")
- {
- data = GetData("fa_SupportMenu", 3000, 1);
- PressKey = data;
- }
- if (PressKey != "")
- {
- var dialdata = db.IvrDialPlans.FirstOrDefault(p => p.Title == "MainIVR" && p.ParentId == ivrDialPlan.Id && p.KeyOfDialPlan == PressKey);
- if (dialdata != null)
- SipName = dialdata.ValueOfKey;
- }
- if (SipName == "Fax")
- {
- Exec("Dial", "IAX2/1001,,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- var channelstatus = GetChannelStatus();
- Console.WriteLine("Channelstatus : " + channelstatus);
- }
- else if (SipName == "CustomerCharge")
- {
- CustomerCharge = true;
- Console.WriteLine("CustomerCharge is true");
- }
- else if (SipName.Substring(0, 2) != "99")
- {
- Console.WriteLine("Dial To " + SipName);
- callState.AgentId = SipName; // just for GoldnetIvr because the is no queue
- db.SaveChanges();
- var QueueOfSip = db.IvrQueueMembers.Where(o => o.membername == SipName).Select(o => o.queue_name).FirstOrDefault();
- maxLine = db.IvrQueues.Where(o => o.name == QueueOfSip).Select(o => o.queue_member_count).FirstOrDefault();
- Console.WriteLine("Name Of Queue :" + QueueOfSip + " &MaxLine : " + maxLine);
- var InQueueCount = db.IvrCallStates.Where(p => (new string[] { "RINGNOANSWER", "ENTERQUEUE" }).Contains(p.status) && p.cdrid == null && p.queue == QueueOfSip && SqlFunctions.DateDiff("mi", p.timestamp, DateTime.Now) < 60).Count();
- if (QueueOfSip != null)
- {
- if (maxLine <= InQueueCount)
- {
- callState.status = "QueueIsFull";
- QueueIsFull = true;
- StreamFile("fa_BusySip");
- StreamFile("fa_PleaseCallAgain");
- }
- else
- {
- bool q = this.queue(QueueOfSip, identifier, priority, false, QuOption);
- }
- }
- else
- {
- Exec("Dial", "SIP/" + SipName + ",30,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- if (dialstatus == "CHANUNAVAIL" && dialstatus == "BUSY")
- {
- StreamFile("fa_BusySip");
- if (counterCall < 2)
- {
- RepeatMainMenu = true;
- counterCall++;
- }
- StreamFile("fa_PleaseCallAgain");
- }
- if (dialstatus == "NOANSWER")
- {
- StreamFile("fa_NoAnswerSip");
- if (counterCall < 2)
- {
- RepeatMainMenu = true;
- counterCall++;
- }
- Console.WriteLine("In no answer mode : " + RepeatMainMenu);
- }
- }
- }
- else
- {
- var data1 = GetData("beep", 5000, 11);
- string dialnum = data1;
- Console.WriteLine("Rabeteh DialedNumber:::: " + dialnum);
- Exec("Dial", "SIP/cisco/#88" + dialnum + ",45,tr");
- var dialstatus = GetVariable("DIALSTATUS");
- Console.WriteLine("DialStatus : " + dialstatus);
- var channelstatus = GetChannelStatus();
- Console.WriteLine("Channelstatus : " + channelstatus);
- }
- }
- #region old DialPlan
- //bool CustomerCharge = false;
- //Console.WriteLine("In Main Ivr");
- //data = GetData("fa_MainIVR", 5000, 4);
- //string EnteredKey = data;
- //IvrDialPlan ivrDialPlan = null;
- //if (EnteredKey != "")
- //{
- // ivrDialPlan = db.IvrDialPlans.FirstOrDefault(p => p.Title == "MainIVR" && p.ParentId == 0 && p.KeyOfDialPlan == EnteredKey);
- // if (ivrDialPlan != null)
- // SipName = ivrDialPlan.ValueOfKey;
- // else
- // SipName = data;
- // Console.WriteLine("SipName ::: " + SipName);
- // if (SipName != "Fax" && SipName != "CustomerCharge")
- // {
- // if (SipName == "Support")
- // {
- // data = GetData("fa_SupportMenu", 4000, 1);
- // string PressKey = data;
- // var Support = db.IvrDialPlans.FirstOrDefault(p => p.Title == "MainIVR" && p.ParentId == ivrDialPlan.Id && p.KeyOfDialPlan == PressKey);
- // if (Support != null)
- // SipName = Support.ValueOfKey;
- // }
- // if (SipName == "GPSMenu")
- // {
- // data = GetData("fa_GpsMenu", 4000, 1);
- // string PressKey = data;
- // var Support = db.IvrDialPlans.FirstOrDefault(p => p.Title == "MainIVR" && p.ParentId == ivrDialPlan.Id && p.KeyOfDialPlan == PressKey);
- // if (Support != null)
- // SipName = Support.ValueOfKey;
- // }
- // if (SipName == "nejati")
- // {
- // Exec("Dial", "SIP/cisco/#8838473980,45,tr");
- // var dialstatus = GetVariable("DIALSTATUS");
- // Console.WriteLine("DialStatus : " + dialstatus);
- // var channelstatus = GetChannelStatus();
- // Console.WriteLine("Channelstatus : " + channelstatus);
- // }
- // else if (SipName.Substring(0, 2) != "99")
- // {
- // Console.WriteLine("Dial To " + SipName);
- // callState.AgentId = SipName; // just for GoldnetIvr because the is no queue
- // db.SaveChanges();
- // var QueueOfSip = db.IvrQueueMembers.Where(o => o.membername == SipName).Select(o => o.queue_name).FirstOrDefault();
- // maxLine = db.IvrQueues.Where(o => o.name == QueueOfSip).Select(o => o.queue_member_count).FirstOrDefault();
- // Console.WriteLine("Name Of Queue :" + QueueOfSip + " &MaxLine : " + maxLine);
- // var InQueueCount = db.IvrCallStates.Where(p => (new string[] { "RINGNOANSWER", "ENTERQUEUE" }).Contains(p.status) && p.cdrid == null && p.queue == QueueOfSip && SqlFunctions.DateDiff("mi", p.timestamp, DateTime.Now) < 60).Count();
- // if (QueueOfSip != null)
- // {
- // if (maxLine <= InQueueCount)
- // {
- // callState.status = "QueueIsFull";
- // QueueIsFull = true;
- // StreamFile("fa_BusySip");
- // StreamFile("fa_PleaseCallAgain");
- // }
- // else
- // {
- // bool q = this.queue(QueueOfSip, identifier, priority, false, QuOption);
- // }
- // }
- // else
- // {
- // Exec("Dial", "SIP/" + SipName + ",30,tr");
- // var dialstatus = GetVariable("DIALSTATUS");
- // Console.WriteLine("DialStatus : " + dialstatus);
- // if (dialstatus == "CHANUNAVAIL" && dialstatus == "BUSY")
- // {
- // StreamFile("fa_BusySip");
- // StreamFile("fa_PleaseCallAgain");
- // }
- // }
- // }
- // else // for software Rabeteh
- // {
- // var data1 = GetData("beep", 5000, 11);
- // string dialnum = data1;
- // Console.WriteLine("Rabeteh DialedNumber:::: " + dialnum);
- // Exec("Dial", "SIP/cisco/#88" + dialnum + ",45,tr");
- // var dialstatus = GetVariable("DIALSTATUS");
- // Console.WriteLine("DialStatus : " + dialstatus);
- // var channelstatus = GetChannelStatus();
- // Console.WriteLine("Channelstatus : " + channelstatus);
- // }
- // }
- // else if (SipName == "Fax")
- // {
- // Exec("Dial", "IAX2/1001,,tr");
- // var dialstatus = GetVariable("DIALSTATUS");
- // Console.WriteLine("DialStatus : " + dialstatus);
- // var channelstatus = GetChannelStatus();
- // Console.WriteLine("Channelstatus : " + channelstatus);
- // }
- // else if (SipName == "CustomerCharge")
- // {
- // CustomerCharge = true;
- // Console.WriteLine("CustomerCharge is true");
- // }
- // //if (ra != null && !CustomerCharge)
- // //{
- // // ManagerResponse rr = manager.SendAction(ra);
- // // Console.WriteLine("rr.Message " + rr.Message);
- // //}
- // //manager.Logoff();
- //}
- #endregion old DialPlan
- #region CustomerCharge
- if (CustomerCharge)
- {
- RepeatMainMenu = false;
- Console.WriteLine("in CustomerCharge");
- string telNumber = "";
- string chargeType = "";
- try
- {
- IVRServices.Tariffs tariffInfo = ivrc.GetUserTariffsFull(callerId);
- IVRServices.StatusOfTariffGroups statusoftariff = ivrc.GetStatusOfTariffGroups(callerId);
- int count = 0;
- bool AcceptTel = false;
- if (!statusoftariff.IsGigCharge && !statusoftariff.IsMonthCharge)
- {
- while (count < 3)
- {
- if (count == 0)
- data = GetData("fa_InActiveService", 500, 1);
- else
- data = GetData("fa_TelInActiveService", 500, 1);
- data = GetData("fa_EnterTel2", 7000, 11);
- if (data.StartsWith("0"))
- data = data.Substring(1);
- telNumber = data;
- Console.WriteLine("tellll: " + telNumber);
- tariffInfo = ivrc.GetUserTariffsFull(telNumber);
- statusoftariff = ivrc.GetStatusOfTariffGroups(telNumber);
- if (statusoftariff.IsGigCharge || statusoftariff.IsMonthCharge)
- {
- data = GetData("fa_TelNumberIs", 500, 1);
- for (int i = 0; i < telNumber.Length; i = i + 2)
- {
- string number = telNumber.Substring(i, 2);
- key = CommonScript.SayTwoDigitNumber(this, number, true);
- }
- data = GetData("fa_AcceptTel", 5000, 1);
- if (data == "1")
- {
- count = 4;
- AcceptTel = true;
- }
- else if (data == "3")
- count = 4;
- else if (data == "2")
- count++;
- }
- else
- count++;
- Console.WriteLine("counter of Tel : " + count);
- }
- }
- if (count >= 3 && !AcceptTel)
- {
- data = GetData("fa_InActiveService", 500, 1);
- StreamFile("fa_Final");
- Hangup();
- return;
- }
- if (statusoftariff.IsGigCharge && statusoftariff.IsMonthCharge)
- {
- data = GetData("fa_ChargeMenu", 1000, 1);
- if (data == "1")
- chargeType = "GigCharge";
- else
- chargeType = "MonthCharge";
- }
- if ((statusoftariff.IsGigCharge && !statusoftariff.IsMonthCharge) || chargeType == "GigCharge")
- {
- data = GetData("fa_GetGig", 2000, 2);
- Console.WriteLine("gig: " + data);
- int Gig = Convert.ToInt32(data);
- string TariffId = "";
- switch (Gig)
- {
- case 1:
- TariffId = "1025";
- break;
- case 2:
- TariffId = "1026";
- break;
- case 3:
- TariffId = "1027";
- break;
- case 4:
- TariffId = "1028";
- break;
- case 5:
- TariffId = "1029";
- break;
- case 6:
- TariffId = "1030";
- break;
- case 7:
- TariffId = "1031";
- break;
- case 8:
- TariffId = "1032";
- break;
- case 9:
- TariffId = "1033";
- break;
- case 10:
- TariffId = "1034";
- break;
- default:
- break;
- }
- Console.WriteLine("TariffId = " + TariffId);
- var tariff = tariffInfo.GigCharge.FirstOrDefault(o => o.Id == TariffId);
- if (tariff != null)
- {
- PriceLong = tariff.TotalPrice;
- if (callerId == "05138408626")
- PriceLong = 10000;
- serviceName = tariff.Name;
- }
- string Price = PriceLong.ToString();
- Console.WriteLine("Price: " + Price);
- data = GetData("fa_WantToCharge1", 500, 1);
- switch (Gig.ToString().Length)
- {
- case 1:
- key = CommonScript.SayOneDigitNumber(this, Gig.ToString(), false);
- break;
- case 2:
- key = CommonScript.SayTwoDigitNumber(this, Gig.ToString(), false);
- break;
- }
- data = GetData("fa_WantToCharge2", 500, 1);
- switch (Price.Length)
- {
- case 1:
- key = CommonScript.SayOneDigitNumber(this, Price, false);
- break;
- case 2:
- key = CommonScript.SayTwoDigitNumber(this, Price, false);
- break;
- case 3:
- key = CommonScript.SayThreeDigitNumber(this, Price, false);
- break;
- case 4:
- key = CommonScript.SayFourDigitNumber(this, Price, false);
- break;
- case 5:
- key = CommonScript.SayFiveDigitNumber(this, Price, false);
- break;
- case 6:
- key = CommonScript.SaySixDigitNumber(this, Price, false);
- break;
- case 7:
- key = CommonScript.SaySevenDigitNumber(this, Price, false);
- break;
- default:
- break;
- }
- data = GetData("fa_WantToCharge_Continue", 8000, 1);
- if (data == "1") // Customer Want To Charge
- {
- counterPlaySound = 0;
- rpeatSound = true;
- while (counterPlaySound < 2 && rpeatSound)
- {
- Console.WriteLine("counter : " + counterPlaySound);
- if (counterPlaySound == 0)
- data = GetData("fa_GetMobileNumber1", 4000, 11);
- else
- data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- counterPlaySound++;
- if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- data = data.TrimStart("0".ToCharArray());
- if (!string.IsNullOrEmpty(data) && data.Length > 10)
- data = data.Substring(0, 10);
- if (data.Length == 10)
- {
- rpeatSound = false;
- mobileNumber = data;
- string customertel = telNumber == "" ? callerId : telNumber;
- try
- {
- long pricelong = Convert.ToInt64(Price);
- IvrCharge qm = new IvrCharge
- {
- CustomerTel = customertel,
- Amount = pricelong,
- TariffCode = TariffId,
- TariffName = serviceName,
- MobileNumber = mobileNumber,
- ChargeType = 0 // charge Gig
- };
- db.IvrCharges.Add(qm);
- db.SaveChanges();
- InsertId = qm.Id;
- }
- catch (Exception ex)
- {
- Console.WriteLine("Erorr : " + ex.Message);
- }
- string pricelength = "";
- int IdLength = InsertId.ToString().Length;
- string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- string pin = ConfigurationManager.AppSettings["Pin"];
- string storcodeLen = "";
- if (StoreCode.Length < 10)
- storcodeLen = "0" + StoreCode.Length.ToString();
- else
- storcodeLen = StoreCode.Length.ToString();
- if (Price.Length < 10)
- pricelength = "0" + Price.Length.ToString();
- else
- pricelength = Price.Length.ToString();
- Random rnd = new Random();
- int OrderId = Convert.ToInt32(rnd.Next(10, 99).ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString());
- Int16 @operator = 0; // for charge has value
- Int16 chType = 0; // for charge has value
- int amount = Convert.ToInt32(Price);
- string PaymentCode = "";
- try
- {
- PaymentCode = Payic.PaymentRequest(OrderId, 1, amount, @operator, chType, InsertId.ToString(), "", mobileNumber, pin, customertel, "");
- Console.WriteLine("PayCode::" + PaymentCode);
- }
- catch (Exception ex)
- {
- Console.WriteLine("error for paycode :::" + ex.Message);
- }
- try
- {
- if (PaymentCode != "")
- {
- IvrCharge ivrch = db.IvrCharges.FirstOrDefault(o => o.Id == InsertId);
- ivrch.PaymentCode = PaymentCode;
- db.SaveChanges();
- ManagerConnection manager = new ManagerConnection(
- ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- manager.Login();
- //RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + PaymentCode, 1);
- GetData("fa_ConnectToBank", 1000);
- ManagerResponse rr = manager.SendAction(ra);
- manager.Logoff();
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("errrrrorrrr: " + ex.Message);
- }
- }
- }
- }
- }
- else if ((statusoftariff.IsMonthCharge && !statusoftariff.IsGigCharge) || chargeType == "MonthCharge")
- {
- data = GetData("fa_GetMonth", 500, 2);
- int month = Convert.ToInt32(data);
- string TariffId = "";
- switch (month)
- {
- case 1:
- TariffId = "1044";
- break;
- case 2:
- TariffId = "1049";
- break;
- default:
- break;
- }
- var tariff = tariffInfo.MonthCharge.FirstOrDefault(o => o.Id == TariffId);
- if (tariff != null)
- {
- PriceLong = tariff.TotalPrice;
- Console.WriteLine("Caaaa: " + callerId);
- if (callerId == "05138408626")
- PriceLong = 10000;
- serviceName = tariff.Name;
- }
- string Price = PriceLong.ToString();
- Console.WriteLine("Price: " + Price);
- data = GetData("fa_WantToCharge1", 500, 1);
- key = CommonScript.SayOneDigitNumber(this, month.ToString(), false);
- data = GetData("fa_WantToCharge3", 500, 1);
- switch (Price.Length)
- {
- case 1:
- key = CommonScript.SayOneDigitNumber(this, Price, false);
- break;
- case 2:
- key = CommonScript.SayTwoDigitNumber(this, Price, false);
- break;
- case 3:
- key = CommonScript.SayThreeDigitNumber(this, Price, false);
- break;
- case 4:
- key = CommonScript.SayFourDigitNumber(this, Price, false);
- break;
- case 5:
- key = CommonScript.SayFiveDigitNumber(this, Price, false);
- break;
- case 6:
- key = CommonScript.SaySixDigitNumber(this, Price, false);
- break;
- case 7:
- key = CommonScript.SaySevenDigitNumber(this, Price, false);
- break;
- default:
- break;
- }
- data = GetData("fa_WantToCharge_Continue", 8000, 1);
- if (data == "1") // Customer Want To Charge
- {
- counterPlaySound = 0;
- rpeatSound = true;
- while (counterPlaySound < 2 && rpeatSound)
- {
- Console.WriteLine("counter : " + counterPlaySound);
- if (counterPlaySound == 0)
- data = GetData("fa_GetMobileNumber1", 4000, 11);
- else
- data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- counterPlaySound++;
- if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- data = data.TrimStart("0".ToCharArray());
- if (!string.IsNullOrEmpty(data) && data.Length > 10)
- data = data.Substring(0, 10);
- if (data.Length == 10)
- {
- rpeatSound = false;
- mobileNumber = data;
- try
- {
- long pricelong = Convert.ToInt64(Price);
- string customertel = telNumber == "" ? callerId : telNumber;
- IvrCharge qm = new IvrCharge
- {
- CustomerTel = customertel,
- Amount = pricelong,
- TariffCode = TariffId,
- TariffName = serviceName,
- MobileNumber = mobileNumber,
- ChargeType = 1 // charge Month
- };
- db.IvrCharges.Add(qm);
- db.SaveChanges();
- InsertId = qm.Id;
- }
- catch (Exception ex)
- {
- Console.WriteLine("Erorr : " + ex.Message);
- }
- string pricelength = "";
- // int IdLength = InsertId.ToString().Length;
- string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- string storcodeLen = "";
- if (StoreCode.Length < 10)
- storcodeLen = "0" + StoreCode.Length.ToString();
- else
- storcodeLen = StoreCode.Length.ToString();
- if (Price.Length < 10)
- pricelength = "0" + Price.Length.ToString();
- else
- pricelength = Price.Length.ToString();
- try
- {
- ManagerConnection manager = new ManagerConnection(
- ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- manager.Login();
- RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- GetData("fa_ConnectToBank", 1000);
- ManagerResponse rr = manager.SendAction(ra);
- manager.Logoff();
- }
- catch (Exception ex)
- {
- Console.WriteLine("errrrrorrrr: " + ex.Message);
- }
- }
- }
- }
- }
- else
- data = GetData("fa_InActiveService", 500, 1);
- //#endregion
- //IVRServices.TariffInfoResult[] tariffInfo = ivrc.GetUserTariffs(callerId);
- //if (tariffInfo != null && tariffInfo.Length > 0)
- //{
- // var tariff = tariffInfo.FirstOrDefault(o => o.Name == serviceName);
- // if (tariff != null)
- // {
- // ServiceId = tariff.Id;
- // PriceLong = tariff.TotalPrice;
- // }
- // string Price = PriceLong.ToString();
- // Console.WriteLine("Price: " + Price);
- // data = GetData("fa_WantToCharge", 500, 1);
- // switch (Price.Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, Price, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, Price, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, Price, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, Price, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, Price, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, Price, false);
- // break;
- // case 7:
- // key = CommonScript.SaySevenDigitNumber(this, Price, false);
- // break;
- // default:
- // break;
- // }
- // data = GetData("fa_WantToCharge_Continue", 8000, 1);
- // if (data == "1") // Customer Want To Charge
- // {
- // counterPlaySound = 0;
- // rpeatSound = true;
- // while (counterPlaySound < 2 && rpeatSound)
- // {
- // Console.WriteLine("counter : " + counterPlaySound);
- // if (counterPlaySound == 0)
- // data = GetData("fa_GetMobileNumber1", 4000, 11);
- // else
- // data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- // counterPlaySound++;
- // if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- // data = data.TrimStart("0".ToCharArray());
- // if (!string.IsNullOrEmpty(data) && data.Length > 10)
- // data = data.Substring(0, 10);
- // if (data.Length == 10)
- // {
- // rpeatSound = false;
- // mobileNumber = data;
- // try
- // {
- // long pricelong = Convert.ToInt64(Price);
- // IvrCharge qm = new IvrCharge
- // {
- // CustomerTel = callerId,
- // Amount = pricelong,
- // TariffCode = ServiceId,
- // TariffName = serviceName,
- // MobileNumber = mobileNumber
- // };
- // db.IvrCharges.Add(qm);
- // db.SaveChanges();
- // InsertId = qm.Id;
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("Erorr : " + ex.Message);
- // }
- // string pricelength = "";
- // // int IdLength = InsertId.ToString().Length;
- // string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- // string storcodeLen = "";
- // if (StoreCode.Length < 10)
- // storcodeLen = "0" + StoreCode.Length.ToString();
- // else
- // storcodeLen = StoreCode.Length.ToString();
- // if (Price.Length < 10)
- // pricelength = "0" + Price.Length.ToString();
- // else
- // pricelength = Price.Length.ToString();
- // try
- // {
- // ManagerConnection manager = new ManagerConnection(
- // ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- // int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- // ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- // ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- // manager.Login();
- // RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- // GetData("fa_ConnectToBank", 1000);
- // ManagerResponse rr = manager.SendAction(ra);
- // manager.Logoff();
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("errrrrorrrr: " + ex.Message);
- // }
- // }
- // }
- // }
- //}
- //else
- //{
- // data = GetData("fa_InActiveService", 500, 1);
- // StreamFile("fa_Final");
- // Hangup();
- // return;
- //}
- }
- catch (Exception ex)
- {
- this.log(identifier, IvrLogTypes.Error, ex.Message);
- GetData("fa_ErrorInConnection", 1000);
- }
- }
- #endregion
- }
- #region comment
- //int CustomerStatus = partner.StatusOfCustomerCharge(callerId);
- // Console.WriteLine("CustomerStatus ::: " + CustomerStatus);
- // switch (CustomerStatus)
- // {
- //case 0:
- // data = GetData("fa_InActiveService", 500, 1);
- // break;
- // case 1:
- //string InfoStr = GetInfoOfSpecialService(ic.Get_Trafik_List_For_Sales("hkhosravi", "GoldNetQAZ*!@123", callerId));
- //if (InfoStr != null && InfoStr != "")
- //{
- // ServiceId = InfoStr.Split('*')[0];
- // Price = InfoStr.Split('*')[1];
- // serviceName = InfoStr.Split('*')[2];
- //}
- // Price = ConfigurationManager.AppSettings["Price"];
- //ServiceWrappers.ServiceResponse UserInfo = partner.GetUserInfoViaCustomer(callerId);
- //ServiceWrappers.UserInfo returnObject = (ServiceWrappers.UserInfo)UserInfo.ReturnedObject;
- //if (returnObject != null && returnObject.RemainingTraffic > 0)
- //{
- // data = GetData("fa_Volume", 1000, 1);
- // int reservedTraffic = Convert.ToInt32(returnObject.ReservedTraffic * 1024);
- // Console.WriteLine("reservedTraffic :" + reservedTraffic);
- // int MegTraffic = Convert.ToInt32(returnObject.RemainingTraffic * 1024) + reservedTraffic;
- // string remainingTraffic = MegTraffic.ToString();
- // Console.WriteLine("remainingTraffic :" + remainingTraffic);
- // switch (remainingTraffic.Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, remainingTraffic, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, remainingTraffic, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, remainingTraffic, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, remainingTraffic, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, remainingTraffic, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, remainingTraffic, false);
- // break;
- // default:
- // break;
- // }
- // data = GetData("fa_Meg", 1000, 1);
- //}
- //data = GetData("fa_WantToCharge", 500, 1);
- //switch (Price.Length)
- //{
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, Price, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, Price, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, Price, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, Price, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, Price, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, Price, false);
- // break;
- // case 7:
- // key = CommonScript.SaySevenDigitNumber(this, Price, false);
- // break;
- // default:
- // break;
- //}
- //data = GetData("fa_WantToCharge_Continue", 8000, 1);
- //if (data == "1") // Customer Want To Charge
- //{
- // counterPlaySound = 0;
- // rpeatSound = true;
- // while (counterPlaySound < 2 && rpeatSound)
- // {
- // Console.WriteLine("counter : " + counterPlaySound);
- // if (counterPlaySound == 0)
- // data = GetData("fa_GetMobileNumber", 5000, 11);
- // else
- // data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- // counterPlaySound++;
- // if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- // data = data.TrimStart("0".ToCharArray());
- // if (!string.IsNullOrEmpty(data) && data.Length > 10)
- // data = data.Substring(0, 10);
- // if (data.Length == 10)
- // {
- // rpeatSound = false;
- // mobileNumber = data;
- // try
- // {
- // long pricelong = Convert.ToInt64(Price);
- // IvrCharge qm = new IvrCharge
- // {
- // CustomerTel = callerId,
- // Amount = pricelong,
- // TariffCode = ServiceId,
- // TariffName = serviceName,
- // MobileNumber = mobileNumber
- // };
- // db.IvrCharges.Add(qm);
- // db.SaveChanges();
- // InsertId = qm.Id;
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("Erorr : " + ex.Message);
- // }
- // int pricelength = Price.Length;
- // int IdLength = InsertId.ToString().Length;
- // try
- // {
- // ManagerConnection manager = new ManagerConnection(
- // ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- // int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- // ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- // ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- // manager.Login();
- // Console.WriteLine("before redirect : " + request.Channel.ToString());
- // RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + pricelength.ToString() + Price + IdLength.ToString() + InsertId.ToString(), 1);
- // ManagerResponse rr = manager.SendAction(ra);
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("errrrrorrrr: " + ex.Message);
- // }
- // try
- // {
- // // ChargResult = GetEstelamService(ic.Sales_Trafik_To_Customer("hkhosravi", "hossein4111", callerId, ServiceId));//do charge from Partneri
- // string resellerId = "1940";
- // string tariffName = "3 گیگ ترافیک مازاد";
- // ChargResult = partner.ChargeCustomer(callerId, resellerId, tariffName).Code.ToString();
- // Console.WriteLine("Charge result:::: " + ChargResult);
- // //ChargResult = "1";
- // }
- // catch
- // {
- // ChargResult = "0";
- // }
- // IvrCharge charge = null;
- // charge = db.IvrCharges.FirstOrDefault(p => p.Id == InsertId);
- // if (ChargResult == "1") //SuccessfulCharge
- // {
- // Console.WriteLine("Successs charge Customer");
- // charge.ChargeResult = Convert.ToInt32(ChargResult);
- // charge.ChargeDate = DateTime.Now;
- // db.SaveChanges();
- // data = GetData("digits/Successful", 500, 1);
- // data = GetData("fa_AccountNumber", 500, 1);
- // for (int i = 0; i < CardNumber.Length; i = i + 2)
- // {
- // string number = CardNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_CallAgainAfterPay", 500, 1);
- // smsresult = SendSMS("شارژ با موفقیت انجام شد", mobileNumber);
- // }
- // else //UnSuccessfulCharge
- // {
- // charge.ChargeResult = Convert.ToInt32(ChargResult);
- // charge.ChargeDate = DateTime.Now;
- // db.SaveChanges();
- // data = GetData("fa_unsuccess", 500, 1);
- // smsresult = SendSMS("عملیات شارژ ناموفق بود", mobileNumber);
- // }
- // Console.WriteLine("smsResult ::: " + smsresult);
- // }
- // else
- // {
- // data = GetData("fa_InvalidMobileNumber", 500, 1);
- // }
- // }
- // }
- // break;
- // case 2:
- // data = GetData("fa_LessThan3Days", 500, 1);
- // data = GetData("fa_AccountNumber", 500, 1);
- // for (int i = 0; i < CardNumber.Length; i = i + 2)
- // {
- // string number = CardNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_CallAgainAfterPay", 500, 1);
- // break;
- // case 3:
- // data = GetData("fa_MoreThan3Days", 500, 1);
- // data = GetData("fa_AccountNumber", 500, 1);
- // for (int i = 0; i < CardNumber.Length; i = i + 2)
- // {
- // string number = CardNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_CallAgainAfterPay", 500, 1);
- // break;
- // case 4:
- // data = GetData("fa_WaitForAcceptPaymentCode", 500, 1);
- // break;
- // default:
- // break;
- // }
- //}
- //else if (data == "2")
- //{
- // IvrCharge charge = null;
- // charge = db.IvrCharges.FirstOrDefault(p => p.CustomerTel == callerId && (p.PaymentCode == null || p.PaymentCode == "") && p.ChargeResult == 1);
- // if (charge != null)
- // {
- // data = GetData("fa_GetTrackingCode", 5000, 16);
- // try
- // {
- // charge.PaymentCode = data;
- // charge.PaymentType = 1; // pay in Card
- // charge.PayDate = DateTime.Now;
- // db.SaveChanges();
- // data = GetData("fa_SuccessSetTrackingCode", 500, 1);
- // }
- // catch (Exception ex)
- // {
- // data = GetData("fa_UnSuccessSetTrackingCode", 500, 1);
- // }
- // }
- // else
- // data = GetData("fa_NoRecord", 500, 1);
- //}
- //else if (data == "3")
- //{
- // data = GetData("fa_AccountNumber", 500, 1);
- // for (int i = 0; i < CardNumber.Length; i = i + 2)
- // {
- // string number = CardNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_CallAgainAfterPay", 500, 1);
- //}
- // }
- //}
- #endregion
- catch (Exception ex)
- {
- this.log(identifier, IvrLogTypes.Error, ex.Message);
- callState.Comment = "Channel was hung up";
- callState.status = "HangUp";
- db.SaveChanges();
- return;
- }
- #endregion
- }
- #region for Parsian Tesr
- ///////////////////////////////////////
- //#region CustomerCharge
- //bool CustomerCharge1 = true;
- //if (CustomerCharge1)
- //{
- // Console.WriteLine("in CustomerCharge");
- // string telNumber = "";
- // string chargeType = "";
- // try
- // {
- // IVRServices.Tariffs tariffInfo = ivrc.GetUserTariffsFull(callerId);
- // IVRServices.StatusOfTariffGroups statusoftariff = ivrc.GetStatusOfTariffGroups(callerId);
- // int count = 0;
- // bool AcceptTel = false;
- // if (!statusoftariff.IsGigCharge && !statusoftariff.IsMonthCharge)
- // {
- // while (count < 3)
- // {
- // if (count == 0)
- // data = GetData("fa_InActiveService", 500, 1);
- // else
- // data = GetData("fa_TelInActiveService", 500, 1);
- // data = GetData("fa_EnterTel2", 7000, 11);
- // if (data.StartsWith("0"))
- // data = data.Substring(1);
- // telNumber = data;
- // Console.WriteLine("tellll: " + telNumber);
- // tariffInfo = ivrc.GetUserTariffsFull(telNumber);
- // statusoftariff = ivrc.GetStatusOfTariffGroups(telNumber);
- // if (statusoftariff.IsGigCharge || statusoftariff.IsMonthCharge)
- // {
- // data = GetData("fa_TelNumberIs", 500, 1);
- // for (int i = 0; i < telNumber.Length; i = i + 2)
- // {
- // string number = telNumber.Substring(i, 2);
- // key = CommonScript.SayTwoDigitNumber(this, number, true);
- // }
- // data = GetData("fa_AcceptTel", 5000, 1);
- // if (data == "1")
- // {
- // count = 4;
- // AcceptTel = true;
- // }
- // else if (data == "3")
- // count = 4;
- // else if (data == "2")
- // count++;
- // }
- // else
- // count++;
- // Console.WriteLine("counter of Tel : " + count);
- // }
- // }
- // if (count >= 3 && !AcceptTel)
- // {
- // data = GetData("fa_InActiveService", 500, 1);
- // StreamFile("fa_Final");
- // Hangup();
- // return;
- // }
- // if (statusoftariff.IsGigCharge && statusoftariff.IsMonthCharge)
- // {
- // data = GetData("fa_ChargeMenu", 1000, 1);
- // if (data == "1")
- // chargeType = "GigCharge";
- // else
- // chargeType = "MonthCharge";
- // }
- // if ((statusoftariff.IsGigCharge && !statusoftariff.IsMonthCharge) || chargeType == "GigCharge")
- // {
- // data = GetData("fa_GetGig", 2000, 2);
- // Console.WriteLine("gig: " + data);
- // int Gig = Convert.ToInt32(data);
- // string TariffId = "";
- // switch (Gig)
- // {
- // case 1:
- // TariffId = "1025";
- // break;
- // case 2:
- // TariffId = "1026";
- // break;
- // case 3:
- // TariffId = "1027";
- // break;
- // case 4:
- // TariffId = "1028";
- // break;
- // case 5:
- // TariffId = "1029";
- // break;
- // case 6:
- // TariffId = "1030";
- // break;
- // case 7:
- // TariffId = "1031";
- // break;
- // case 8:
- // TariffId = "1032";
- // break;
- // case 9:
- // TariffId = "1033";
- // break;
- // case 10:
- // TariffId = "1034";
- // break;
- // default:
- // break;
- // }
- // Console.WriteLine("TariffId = " + TariffId);
- // var tariff = tariffInfo.GigCharge.FirstOrDefault(o => o.Id == TariffId);
- // if (tariff != null)
- // {
- // PriceLong = tariff.TotalPrice;
- // if (callerId == "05138408626")
- // PriceLong = 10000;
- // serviceName = tariff.Name;
- // }
- // string Price = PriceLong.ToString();
- // Console.WriteLine("Price: " + Price);
- // data = GetData("fa_WantToCharge1", 500, 1);
- // switch (Gig.ToString().Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, Gig.ToString(), false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, Gig.ToString(), false);
- // break;
- // }
- // data = GetData("fa_WantToCharge2", 500, 1);
- // switch (Price.Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, Price, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, Price, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, Price, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, Price, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, Price, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, Price, false);
- // break;
- // case 7:
- // key = CommonScript.SaySevenDigitNumber(this, Price, false);
- // break;
- // default:
- // break;
- // }
- // data = GetData("fa_WantToCharge_Continue", 8000, 1);
- // if (data == "1") // Customer Want To Charge
- // {
- // counterPlaySound = 0;
- // rpeatSound = true;
- // while (counterPlaySound < 2 && rpeatSound)
- // {
- // Console.WriteLine("counter : " + counterPlaySound);
- // if (counterPlaySound == 0)
- // data = GetData("fa_GetMobileNumber1", 4000, 11);
- // else
- // data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- // counterPlaySound++;
- // if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- // data = data.TrimStart("0".ToCharArray());
- // if (!string.IsNullOrEmpty(data) && data.Length > 10)
- // data = data.Substring(0, 10);
- // if (data.Length == 10)
- // {
- // rpeatSound = false;
- // mobileNumber = data;
- // try
- // {
- // long pricelong = Convert.ToInt64(Price);
- // string customertel = telNumber == "" ? callerId : telNumber;
- // IvrCharge qm = new IvrCharge
- // {
- // CustomerTel = customertel,
- // Amount = pricelong,
- // TariffCode = TariffId,
- // TariffName = serviceName,
- // MobileNumber = mobileNumber,
- // ChargeType = 0 // charge Gig
- // };
- // db.IvrCharges.Add(qm);
- // db.SaveChanges();
- // InsertId = qm.Id;
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("Erorr : " + ex.Message);
- // }
- // string pricelength = "";
- // // int IdLength = InsertId.ToString().Length;
- // string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- // string storcodeLen = "";
- // if (StoreCode.Length < 10)
- // storcodeLen = "0" + StoreCode.Length.ToString();
- // else
- // storcodeLen = StoreCode.Length.ToString();
- // if (Price.Length < 10)
- // pricelength = "0" + Price.Length.ToString();
- // else
- // pricelength = Price.Length.ToString();
- // try
- // {
- // ManagerConnection manager = new ManagerConnection(
- // ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- // int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- // ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- // ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- // manager.Login();
- // RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- // GetData("fa_ConnectToBank", 1000);
- // ManagerResponse rr = manager.SendAction(ra);
- // manager.Logoff();
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("errrrrorrrr: " + ex.Message);
- // }
- // }
- // }
- // }
- // }
- // else if ((statusoftariff.IsMonthCharge && !statusoftariff.IsGigCharge) || chargeType == "MonthCharge")
- // {
- // data = GetData("fa_GetMonth", 500, 2);
- // int month = Convert.ToInt32(data);
- // string TariffId = "";
- // switch (month)
- // {
- // case 1:
- // TariffId = "1044";
- // break;
- // case 2:
- // TariffId = "1049";
- // break;
- // default:
- // break;
- // }
- // var tariff = tariffInfo.MonthCharge.FirstOrDefault(o => o.Id == TariffId);
- // if (tariff != null)
- // {
- // PriceLong = tariff.TotalPrice;
- // Console.WriteLine("Caaaa: " + callerId);
- // if (callerId == "05138408626")
- // PriceLong = 10000;
- // serviceName = tariff.Name;
- // }
- // string Price = PriceLong.ToString();
- // Console.WriteLine("Price: " + Price);
- // data = GetData("fa_WantToCharge1", 500, 1);
- // key = CommonScript.SayOneDigitNumber(this, month.ToString(), false);
- // data = GetData("fa_WantToCharge3", 500, 1);
- // switch (Price.Length)
- // {
- // case 1:
- // key = CommonScript.SayOneDigitNumber(this, Price, false);
- // break;
- // case 2:
- // key = CommonScript.SayTwoDigitNumber(this, Price, false);
- // break;
- // case 3:
- // key = CommonScript.SayThreeDigitNumber(this, Price, false);
- // break;
- // case 4:
- // key = CommonScript.SayFourDigitNumber(this, Price, false);
- // break;
- // case 5:
- // key = CommonScript.SayFiveDigitNumber(this, Price, false);
- // break;
- // case 6:
- // key = CommonScript.SaySixDigitNumber(this, Price, false);
- // break;
- // case 7:
- // key = CommonScript.SaySevenDigitNumber(this, Price, false);
- // break;
- // default:
- // break;
- // }
- // data = GetData("fa_WantToCharge_Continue", 8000, 1);
- // if (data == "1") // Customer Want To Charge
- // {
- // counterPlaySound = 0;
- // rpeatSound = true;
- // while (counterPlaySound < 2 && rpeatSound)
- // {
- // Console.WriteLine("counter : " + counterPlaySound);
- // if (counterPlaySound == 0)
- // data = GetData("fa_GetMobileNumber1", 4000, 11);
- // else
- // data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- // counterPlaySound++;
- // if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- // data = data.TrimStart("0".ToCharArray());
- // if (!string.IsNullOrEmpty(data) && data.Length > 10)
- // data = data.Substring(0, 10);
- // if (data.Length == 10)
- // {
- // rpeatSound = false;
- // mobileNumber = data;
- // try
- // {
- // long pricelong = Convert.ToInt64(Price);
- // string customertel = telNumber == "" ? callerId : telNumber;
- // IvrCharge qm = new IvrCharge
- // {
- // CustomerTel = customertel,
- // Amount = pricelong,
- // TariffCode = TariffId,
- // TariffName = serviceName,
- // MobileNumber = mobileNumber,
- // ChargeType = 1 // charge Month
- // };
- // db.IvrCharges.Add(qm);
- // db.SaveChanges();
- // InsertId = qm.Id;
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("Erorr : " + ex.Message);
- // }
- // string pricelength = "";
- // // int IdLength = InsertId.ToString().Length;
- // string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- // string storcodeLen = "";
- // if (StoreCode.Length < 10)
- // storcodeLen = "0" + StoreCode.Length.ToString();
- // else
- // storcodeLen = StoreCode.Length.ToString();
- // if (Price.Length < 10)
- // pricelength = "0" + Price.Length.ToString();
- // else
- // pricelength = Price.Length.ToString();
- // try
- // {
- // ManagerConnection manager = new ManagerConnection(
- // ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- // int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- // ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- // ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- // manager.Login();
- // RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- // GetData("fa_ConnectToBank", 1000);
- // ManagerResponse rr = manager.SendAction(ra);
- // manager.Logoff();
- // }
- // catch (Exception ex)
- // {
- // Console.WriteLine("errrrrorrrr: " + ex.Message);
- // }
- // }
- // }
- // }
- // }
- // else
- // data = GetData("fa_InActiveService", 500, 1);
- // //#endregion
- // //IVRServices.TariffInfoResult[] tariffInfo = ivrc.GetUserTariffs(callerId);
- // //if (tariffInfo != null && tariffInfo.Length > 0)
- // //{
- // // var tariff = tariffInfo.FirstOrDefault(o => o.Name == serviceName);
- // // if (tariff != null)
- // // {
- // // ServiceId = tariff.Id;
- // // PriceLong = tariff.TotalPrice;
- // // }
- // // string Price = PriceLong.ToString();
- // // Console.WriteLine("Price: " + Price);
- // // data = GetData("fa_WantToCharge", 500, 1);
- // // switch (Price.Length)
- // // {
- // // case 1:
- // // key = CommonScript.SayOneDigitNumber(this, Price, false);
- // // break;
- // // case 2:
- // // key = CommonScript.SayTwoDigitNumber(this, Price, false);
- // // break;
- // // case 3:
- // // key = CommonScript.SayThreeDigitNumber(this, Price, false);
- // // break;
- // // case 4:
- // // key = CommonScript.SayFourDigitNumber(this, Price, false);
- // // break;
- // // case 5:
- // // key = CommonScript.SayFiveDigitNumber(this, Price, false);
- // // break;
- // // case 6:
- // // key = CommonScript.SaySixDigitNumber(this, Price, false);
- // // break;
- // // case 7:
- // // key = CommonScript.SaySevenDigitNumber(this, Price, false);
- // // break;
- // // default:
- // // break;
- // // }
- // // data = GetData("fa_WantToCharge_Continue", 8000, 1);
- // // if (data == "1") // Customer Want To Charge
- // // {
- // // counterPlaySound = 0;
- // // rpeatSound = true;
- // // while (counterPlaySound < 2 && rpeatSound)
- // // {
- // // Console.WriteLine("counter : " + counterPlaySound);
- // // if (counterPlaySound == 0)
- // // data = GetData("fa_GetMobileNumber1", 4000, 11);
- // // else
- // // data = GetData("fa_GetCorrectMobileNumber", 4000, 11);
- // // counterPlaySound++;
- // // if (!string.IsNullOrEmpty(data) && data.StartsWith("0"))
- // // data = data.TrimStart("0".ToCharArray());
- // // if (!string.IsNullOrEmpty(data) && data.Length > 10)
- // // data = data.Substring(0, 10);
- // // if (data.Length == 10)
- // // {
- // // rpeatSound = false;
- // // mobileNumber = data;
- // // try
- // // {
- // // long pricelong = Convert.ToInt64(Price);
- // // IvrCharge qm = new IvrCharge
- // // {
- // // CustomerTel = callerId,
- // // Amount = pricelong,
- // // TariffCode = ServiceId,
- // // TariffName = serviceName,
- // // MobileNumber = mobileNumber
- // // };
- // // db.IvrCharges.Add(qm);
- // // db.SaveChanges();
- // // InsertId = qm.Id;
- // // }
- // // catch (Exception ex)
- // // {
- // // Console.WriteLine("Erorr : " + ex.Message);
- // // }
- // // string pricelength = "";
- // // // int IdLength = InsertId.ToString().Length;
- // // string StoreCode = ConfigurationManager.AppSettings["StoreCode"];
- // // string storcodeLen = "";
- // // if (StoreCode.Length < 10)
- // // storcodeLen = "0" + StoreCode.Length.ToString();
- // // else
- // // storcodeLen = StoreCode.Length.ToString();
- // // if (Price.Length < 10)
- // // pricelength = "0" + Price.Length.ToString();
- // // else
- // // pricelength = Price.Length.ToString();
- // // try
- // // {
- // // ManagerConnection manager = new ManagerConnection(
- // // ConfigurationManager.AppSettings["Asterisk.Manager.Ip"],
- // // int.Parse(ConfigurationManager.AppSettings["Asterisk.Manager.Port"]),
- // // ConfigurationManager.AppSettings["Asterisk.Manager.User"],
- // // ConfigurationManager.AppSettings["Asterisk.Manager.Secret"]);
- // // manager.Login();
- // // RedirectAction ra = new RedirectAction(request.Channel.ToString(), "Pecopayment", "2020" + storcodeLen + StoreCode + pricelength + Price + InsertId.ToString(), 1);
- // // GetData("fa_ConnectToBank", 1000);
- // // ManagerResponse rr = manager.SendAction(ra);
- // // manager.Logoff();
- // // }
- // // catch (Exception ex)
- // // {
- // // Console.WriteLine("errrrrorrrr: " + ex.Message);
- // // }
- // // }
- // // }
- // // }
- // //}
- // //else
- // //{
- // // data = GetData("fa_InActiveService", 500, 1);
- // // StreamFile("fa_Final");
- // // Hangup();
- // // return;
- // //}
- // }
- // catch (Exception ex)
- // {
- // this.log(identifier, IvrLogTypes.Error, ex.Message);
- // GetData("fa_ErrorInConnection", 1000);
- // }
- //}
- //#endregion
- #endregion
- StreamFile("fa_Final");
- Hangup();
- return;
- }
- }
- public static int SendSMS(string result, string recipient)
- {
- string ServiceUse = ConfigurationManager.AppSettings["SmsServiceUsed"];
- Console.WriteLine("ServiceUse : " + ServiceUse);
- Console.WriteLine("recipient : " + recipient);
- if (ServiceUse == "Rightel")
- {
- HttpWebRequest HTTP_Request = (HttpWebRequest)WebRequest.Create("http://91.229.215.222/service/sendsms.php?sim=" + recipient + "&text=" + result);
- HTTP_Request.Method = "POST";
- HTTP_Request.ContentType = "application/x-www-form-urlencoded";
- //HTTP_Request.ContentLength = Data.Length;
- Stream NewStream = HTTP_Request.GetRequestStream();
- // NewStream.Write(Data, 0, Data.Length);
- NewStream.Close();
- WebResponse Response = HTTP_Request.GetResponse();
- Stream ResponseStream = Response.GetResponseStream();
- StreamReader ResponseReader = new StreamReader(ResponseStream);
- return int.Parse(ResponseReader.ReadToEnd());
- }
- else if (ServiceUse == "Hostiran")
- {
- Console.WriteLine("In Hostiran Block");
- SmsService.SmsWebServicePortClient ic = new SmsService.SmsWebServicePortClient();
- int SendResult = ic.send("goldnet1", "789654", "0" + recipient, result, "", 0);
- return SendResult;
- }
- else
- return 0;
- }
- //private void LoadConfigConnection()
- //{
- // ServiceWrappers.Patner ar = new ServiceWrappers.Patner();
- // string servers = ConfigurationManager.AppSettings["AgentReseller.WS.Server"];
- // string username = ConfigurationManager.AppSettings["AgentReseller.WS.Username"];
- // string password = ConfigurationManager.AppSettings["AgentReseller.WS.Password"];
- // ServiceWrappers.ConnectionInfoCollection cIC = new ServiceWrappers.ConnectionInfoCollection();
- // string[] allServers = servers.Split('*');
- // for (int i = 0; i < allServers.Length; i++)
- // {
- // ServiceWrappers.ConnectionInfo tmpCInfo = new ServiceWrappers.ConnectionInfo("AgentReseller" /*+ i.ToString()*/, allServers[i], "-1", username, password);
- // cIC.AddConnection(tmpCInfo);
- // }
- // ar.SetConnectionStrings(cIC);
- //}
- public static string GetEstelamService(string XMLStr)
- {
- XDocument doc = XDocument.Parse(XMLStr);
- var list = doc.Root.Elements("code").Select(element => element.Value).FirstOrDefault();
- return list;
- }
- //public static string GetInfoOfSpecialService(string XMLStr, string serviceName = "3 گیگ ترافیک مازاد")
- //{
- // XDocument doc = XDocument.Parse(XMLStr);
- // var list = doc.Root.Elements()
- // .Select(row => new MyServices(int.Parse(row.Element("service_id").Value),
- // row.Element("service_name").Value,
- // row.Element("service_price").Value,
- // row.Element("service_credit").Value)).ToList();
- // var foundItem = list.SingleOrDefault(item => item.ServiceName == serviceName);
- // return foundItem.ServiceId + "*" + foundItem.ServicePrice + "*" + serviceName;
- //}
- static void DoSomething()
- {
- try
- {
- try
- {
- var ic = new ResellerPanelService.ResellerPanelServiceClient(); // Main Server
- //var ic = new ServiceReference1.ResellerPanelServiceClient(); // test server
- Console.WriteLine("After new webserviceee");
- ResellerId = ic.GetOwnerResellerCisco(callerId);
- Console.WriteLine("After Get Data from WebService");
- }
- catch (ThreadAbortException)
- {
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("error Service :" + ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement