Example #1
0
        public string  RegisterAndUnregisterSip(string connectionString, FreeSwitchRegisterParameters requestParams)
        {
            string status = String.Empty;

            try
            {
                Press3.BusinessRulesLayer.SipPhoneRegistration sips = new Press3.BusinessRulesLayer.SipPhoneRegistration();
                JObject registrationdetails = sips.RegisterAndUnRegister(connectionString, requestParams);
                this.Message = registrationdetails.SelectToken("Message").ToString();
            }catch (Exception ex) {
                Logger.Error("Exception while unregistering sip user:" + ex.ToString());
            }


            return(this.Message);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            String xml = string.Empty;
            string usernameRegularExpression = "^[a-zA-Z0-9]+$";
            Regex  usernameRegex             = new Regex("^[0-9]+$", RegexOptions.Compiled);



            try
            {
                string isSave = AppConfig.GetApplicationKey("SaveFreeSwitchRequest");
                if (isSave == "1")
                {
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/FreeSwitchRequest/")))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/FreeSwitchRequest/"));
                        Logger.Info("Freeswitch requsts directory created in softphone register .");
                    }


                    string path = HttpContext.Current.Server.MapPath("~/FreeSwitchRequest/") + System.DateTime.Now.ToString("yyyyMMddHHmmss");
                    HttpContext.Current.Request.SaveAs(path + ".txt", true);
                    Logger.Debug("Freeswitch softphone register Request is saved in " + path);
                }



                Press3.UserDefinedClasses.FreeSwitchRegisterParameters requestParameter = new FreeSwitchRegisterParameters(context);


                if (requestParameter.IsSofia)
                {
                    xml = RegisterAndUnregisterSip(MyConfig.MyConnectionString, requestParameter);
                }
                else if (requestParameter.RegisterUser != null || requestParameter.RegisterDomain != null)
                {
//                    Logger.Info("Registered user: "******"Registered user in else: " + requestParameter.RegisterUser.ToString());
                        this.Message = "<Response>username contains invalid characters</Response>";
                    }


                    if (!string.IsNullOrEmpty(Password) && Password != "0")
                    {
                        xml = FrameRegiterUserXml(requestParameter.RegisterUser, requestParameter.RegisterDomain, this.Password);
                    }
                    else
                    {
                        xml = this.Message;
                    }
                }
                else
                {
                    xml = "<Response>Mandatatry parameters are missing</Response>";
                }


                //if(!requestParameter.IsSofia)
                // Logger.Info("SoftPhone Xml generated the user:"******",Event Name:" + requestParameter.EventName + ",\nXml:" + xml.Replace("\n", "").Replace("\r", ""));
                SendXmlResponse(context, xml);
            }catch (Exception ex) {
                Logger.Error("Exception while processing request:" + ex.ToString());
            }
        }