/// <summary>
        /// Check Account details Approved/Disabled/Expired
        /// </summary>
        /// <param name="HDInfo">Harddisk number</param>
        /// <param name="username">PC LogIn Username</param>
        public async void SetAuthDetail(string HDInfo, string username)
        {
            try
            {
                DataAccess ServiceObj = new DataAccess();
                HRDsqApi.DataAccess.User objuserinfo = new HRDsqApi.DataAccess.User();
                List <HRDsqApi.DataAccess.UserHDDInfo> userhddinfo = new List <HRDsqApi.DataAccess.UserHDDInfo>();
                userhddinfo.Add(new HRDsqApi.DataAccess.UserHDDInfo {
                    HDDNumber = HDInfo.ToString(), IsServer = true
                });
                objuserinfo.UserHDDInfo = userhddinfo;

                // call api and check for Status New/Pending/Approved/Disable
                objuserinfo = await ServiceObj.GetServerDetail(objuserinfo);

                string subcription = string.Empty;
                int    SMScount    = 0;
                ExtractLibrary.WriteInLogFile("user status: " + objuserinfo.Message);

                if (objuserinfo.Message.ToLower().ToString().Trim() == "approved")
                {
                    HrdsqLicenseUserId = objuserinfo.HrdsqLicenseUserId;
                    HrdsqLicenseKey    = objuserinfo.HrdsqLicenseKey;

                    //Library.WriteErrorLog("HrdsqLicenseUserId our id" + HrdsqLicenseUserId);
                    //Library.WriteErrorLog("HrdsqLicenseKey our key" + HrdsqLicenseKey);


                    foreach (var item in objuserinfo.UserHDDInfo)
                    {
                        SipUsername  = item.SipUsername;
                        Sippassword  = item.Sippassword;
                        Sipserver    = item.Sipserver;
                        Sipport      = item.Sipport;
                        subcription  = item.Subscription;
                        SMScount     = item.Count;
                        SMSFNo       = objuserinfo.SMSFromNumber;
                        SMSAuthID    = item.AuthID;
                        SMSAuthToken = item.AuthToken;
                        Logmachine   = item.IPAddress; //Temp Using IP for LogMachine Filed.
                        dbUserId     = item.ID;
                        //-----------Added by Vandna on 12-May-2017-------
                        IsSipVoipSDKlog = objuserinfo.IsSipVoipSDKLog;
                        IsTransPortTCP  = item.IsTransPortTCP;
                        IsDebugMode     = item.IsDebugMode;
                        //--------------End--------------------
                    }
                    DrPhoneNumber = objuserinfo.PhoneNumber;

                    //-----------Added by Vandna on 05-Jan-2017--
                    uAuthID    = objuserinfo.uAuthID;
                    uAuthToken = objuserinfo.uAuthToken;
                    // Library.WriteErrorLog("My auth token" + uAuthToken);
                    uApiKey      = objuserinfo.uApiKey;
                    ProviderType = objuserinfo.ProviderType;

                    Library.WriteErrorLog("IsDebugMode : " + IsDebugMode + " AuthToken: " + uAuthToken);
                    //----End-----

                    //--------------End--------------------

                    if (SipUsername.ToString().Trim() == "" || SipUsername.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SIP username.");
                    }
                    else if (Sippassword.ToString().Trim() == "" || Sippassword.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SIP password.");
                    }
                    else if (Sipserver.ToString().Trim() == "" || Sipserver.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SIP Server.");
                    }
                    else if (Sipport.ToString().Trim() == "" || Sipport.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SIP port number.");
                    }
                    else if (SMSFNo.ToString().Trim() == "" || SMSFNo.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SMS from number.");
                    }
                    else if (SMSAuthID.ToString().Trim() == "" || SMSAuthID.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SMS auth id.");
                    }
                    else if (SMSAuthToken.ToString().Trim() == "" || SMSAuthToken.ToString().Trim() == "-")
                    {
                        Library.WriteErrorLog("Please provide SIP password.");
                    }

                    RegisterToHRDsq(SMSFNo, SMSAuthID, SMSAuthToken, IsSipVoipSDKlog, IsTransPortTCP, IsDebugMode, uApiKey, ProviderType, DrPhoneNumber);
                }
                else
                {
                    Library.WriteErrorLog("Else case -- " + objuserinfo.Message.ToLower().ToString().Trim());
                    switch (objuserinfo.Message.ToLower().ToString().Trim())
                    {
                    case "new":
                        ProcessExtensions.StartProcessAsCurrentUser(AppDomain.CurrentDomain.BaseDirectory + "\\ConvergedComm.exe", "new");
                        break;

                    case "pending":
                        ProcessExtensions.StartProcessAsCurrentUser(AppDomain.CurrentDomain.BaseDirectory + "\\ConvergedComm.exe", "pending");
                        break;

                    case "expired":
                        ProcessExtensions.StartProcessAsCurrentUser(AppDomain.CurrentDomain.BaseDirectory + "\\ConvergedComm.exe", "expired");
                        OnStop();
                        break;

                    case "disable":
                        OnStop();
                        ProcessExtensions.StartProcessAsCurrentUser(AppDomain.CurrentDomain.BaseDirectory + "\\ConvergedComm.exe", "disable");
                        break;

                    default:

                        Library.WriteErrorLog(objuserinfo.Message.ToLower().ToString().Trim());

                        break;
                    }
                }


                //Added On 15-Sept-18
                //string frpRoot = AppDomain.CurrentDomain.BaseDirectory + "\\frp";
                //string frpDest = @"C:\frp";

                //foreach (var file in Directory.GetFiles(frpDest))
                //{
                //    if (!Directory.Exists(frpRoot))
                //    {
                //        Directory.CreateDirectory(frpRoot);
                //    }
                //    File.Copy(file, Path.Combine(frpRoot, Path.GetFileName(file)));
                //}
                //------------------------------



                //string path2 = @"C:\Program Files (x86)\HRDSQPlugin\HRDSQPlugin\HRDSQTray.exe";
                //if (!IsProcessOpen("HRDSQTray.exe"))
                //{
                //    ProcessStartInfo stinfo = new ProcessStartInfo();
                //    stinfo.FileName = @"C:\Program Files (x86)\HRDSQPlugin\HRDSQPlugin\HRDSQTray.exe";
                //    stinfo.CreateNoWindow = true;
                //    stinfo.UseShellExecute = false;
                //    stinfo.Arguments = "-c " + "\"" + path2 + "\"";
                //    stinfo.RedirectStandardOutput = true;
                //    Process myProcess2 = Process.Start(stinfo);


                //    while (!myProcess2.StandardOutput.EndOfStream)
                //    {
                //        Library.WriteErrorLog("FRP LOG " + myProcess2.StandardOutput.ReadLine());
                //    }

                //}
                string text = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\frp\\frpc.ini").Replace("$Token", (string.IsNullOrEmpty(uAuthToken) == true ? "$Token": uAuthToken));

                System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "\\frp\\frpc.ini", text);

                //-----------------------------------------
                //sWorkingDir = AppDomain.CurrentDomain.BaseDirectory + "\\frp\\frpc.exe";
                //sWorkingDir = "@" + sWorkingDir.Replace(@"\\", @"\");
                //Library.WriteErrorLog("sWorkingDir" + sWorkingDir);
                //string iniFile = AppDomain.CurrentDomain.BaseDirectory + "\\frp\\frpc.ini";
                //iniFile = @"-c " + iniFile.Replace(@"\\", @"\");
                //Library.WriteErrorLog("iniFile" + iniFile);



                //------------------------------------------
                string path = @"C:\Program Files (x86)\HRDSQPlugin\HRDSQPlugin\frp\frpc.ini";

                if (!IsProcessOpen("frpc.exe"))
                {
                    ProcessStartInfo stinfo = new ProcessStartInfo();
                    stinfo.FileName               = @"C:\Program Files (x86)\HRDSQPlugin\HRDSQPlugin\frp\frpc.exe";
                    stinfo.CreateNoWindow         = true;
                    stinfo.UseShellExecute        = false;
                    stinfo.Arguments              = "-c " + "\"" + path + "\"";
                    stinfo.RedirectStandardOutput = true;
                    Process myProcess = Process.Start(stinfo);

                    while (!myProcess.StandardOutput.EndOfStream)
                    {
                        Library.WriteErrorLog("FRP LOG " + myProcess.StandardOutput.ReadLine());
                    }

                    //    //Library.WriteErrorLog("FRP Service Start");
                    //    //Process proc = new Process();
                    //    //proc.StartInfo.FileName = sWorkingDir;
                    //    //proc.StartInfo.CreateNoWindow = true;
                    //    //proc.StartInfo.UseShellExecute = false;
                    //    //proc.StartInfo.Arguments = @"-c " + iniFile;  //@"-c c:\frp\frpc.ini";
                    //    //proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                    //    //proc.StartInfo.RedirectStandardOutput = true;

                    //    //Library.WriteErrorLog("FRP Process START");
                    //    //proc.Start();
                    //    //while (!proc.StandardOutput.EndOfStream)
                    //    //{
                    //    //    Library.WriteErrorLog(proc.StandardOutput.ReadLine());
                    //    //}
                    //}

                    //-------------------------------------------------------
                }
            }
            catch (Exception pcex)
            {
                Library.WriteErrorLog("FRPError " + pcex.Message);
            }
        }
        protected override void OnStart(string[] args)
        {
            try
            {
                Library.WriteErrorLog(" =============  Service Start ===============");

                // Register Sip SDK on client machine registry
                // RegisterSIPSDK();

                CLS = new DentalPlugin.CommonPlugin();

                // For Check LogFile size and delete log file , if size is greater than 10 MB
                DeleteLogFile();

                #region  //  Check HRDsq Tray is running or not

                if (IsProcessOpen())
                {
                    try
                    {
                        // Start HRDSQ Tray on System
                        ProcessExtensions.StartProcessAsCurrentUser(AppDomain.CurrentDomain.BaseDirectory + "\\ConvergedComm.exe", "OpenTray");
                    }
                    catch (Exception)
                    {
                        // No Need to handle this because Now PC in log off mode,We don't need to open Tray
                    }
                }

                #endregion

                // Create Reports folder in installtion directory if not exist.
                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Reports"))
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Reports");
                }

                #region // Get System Harddisk number and Username

                //string appPath = Directory.GetCurrentDirectory();
                //string[] aPath;
                //aPath = appPath.ToString().Trim().Split(':');
                //if (aPath.Length > 0) { appPath = aPath[0].ToString(); }
                //-----Roopal-------------
                _objHD    = new HDInfo();
                strHDInfo = clsHDInfo.MacAddress();
                //_objHD.getUniqueID("");
                Library.WriteErrorLog("HDInfo:" + strHDInfo);
                Username = GetUserName();
                Library.WriteErrorLog("Username:"******"" && !string.IsNullOrEmpty(Username))
                {
                    SetAuthDetail(strHDInfo.ToString().Trim(), Username.Trim().ToLower());
                }
            }
            catch (Exception ex)
            {
                Library.WriteErrorLog("Service Start Error :" + ex.Message);
            }
        }
Exemple #3
0
 protected override void OnStart(string[] args)
 {
     ProcessExtensions.StartProcessAsCurrentUser("calc.exe");
 }