protected void Page_Load(object sender, EventArgs e)
        {
            txtMobile.Text = "";
            CompanyConfig cc = new CompanyConfig();

            DataTable dtc = cc.getCompanyInfo();

            if (dtc.Rows.Count > 0)
            {
                // lblCompanyName.Text = ""; // dtc.Rows[0]["Configvalue"].ToString();
            }

            if (Session["EmpID"] == null)
            {
                EndSession();
            }
            else
            {
                EmployeeCls ecls = new EmployeeCls();
                DataTable   dt   = ecls.getEmployeeInfo(Session["EmpID"].ToString());
                if (dt.Rows.Count > 0)
                {
                    lblUserName.Text = "Hi welcome " + dt.Rows[0]["EmpName"].ToString() + "-" + dt.Rows[0]["EmpRoleName"].ToString();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CompanyConfig cc = new CompanyConfig();

            DataTable dtc = cc.getCompanyInfo();

            if (dtc.Rows.Count > 0)
            {
                //lblCompanyName.Text = dtc.Rows[0]["Configvalue"].ToString();
            }

            if (Session["EmpID"] == null)
            {
                // FormsAuthentication.SignOut();
                EndSession();
            }
            else
            {
                EmployeeCls ecls = new EmployeeCls();
                DataTable   dt   = ecls.getEmployeeInfo(Session["EmpID"].ToString());
                if (dt.Rows.Count > 0)
                {
                    //Response.Write(dt.Rows[0]["EmpID"].ToString());
                    //Response.Write(dt.Rows[0]["EmpName"].ToString());
                    //Response.Write(dt.Rows[0]["EmpRoleID"].ToString());
                    //Response.Write(dt.Rows[0]["EmpRoleName"].ToString());
                    string roomNo = dt.Rows[0]["DefaultRoomID"].ToString();
                    lblUserName.Text = "Hi welcome " + dt.Rows[0]["EmpName"].ToString() + "-" + dt.Rows[0]["EmpRoleName"].ToString();
                    if (roomNo != "0")
                    {
                        lblRoomNo.Text = "Room " + roomNo;
                    }
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="cancelRunner"></param>
        /// <param name="companyConfig"></param>
        /// <param name="runnerProgress"></param>
        /// <returns></returns>
        private ServiceTaskResult RunWindowsService(CancellationToken cancelRunner, CompanyConfig companyConfig,
                                                    ServiceProgressInfo runnerProgress)
        {
            // NOTE: In order to get the initial code delivered, I am reusing the code, or parts of it at least,
            //		 from the original MakoRunner project that uses the Topshelf library. This is not ideal since
            //		 we lose a great deal of control over our services. However, we know the code works for one
            //		 company ID at a time, which is why I'm reusing here, in the Sequential portion of the IF clause.

            //
            TopshelfExitCode retCode = HostFactory.Run(x =>
            {
                x.Service <TopshelfWindowsService>(sc =>
                {
                    sc.ConstructUsing(name => new TopshelfWindowsService(companyConfig, runnerProgress));
                    sc.WhenStarted((s, hostControl) => s.Start(hostControl));
                    sc.WhenShutdown(s => s.Shutdown());
                    sc.WhenStopped((s, hostControl) => s.Stop(hostControl));
                });
                //
                x.SetServiceName($"CommRunner {companyConfig.CompanyName + companyConfig.CompanyId}");
                x.SetDescription($"Mako Commission Runner for CompanyID ({companyConfig.CompanyId})");
                x.SetDisplayName($"Mako Commission Runner {companyConfig.CompanyId}");
                //
                //x.StartAutomaticallyDelayed();
            });
            //
            int exitCode = (int)Convert.ChangeType(retCode, retCode.GetTypeCode());

            // Create and return a ServiceTaskResult.
            // TODO: Add properties to the ServiceTaskResult and populate based on service exit code, etc.
            return(new ServiceTaskResult()
            {
                ServiceReturnCode = exitCode
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="companyConfig"></param>
        /// <param name="serviceProgressInfo"></param>
        protected BaseTopshelfWindowsService(CompanyConfig companyConfig, ServiceProgressInfo serviceProgressInfo)
        {
            //
            MakoSocket = new ServicesWebSocket();

            // Create the log provider to log progress.
            if (MakoLogger == null)
            {
                MakoLogger = new DelegateLogProvider();
            }

            // Set the event handler for change events.
            MakoLogger._onProgressUpdate += MakoLogger__onProgressUpdate;

            //
            ServiceProgressInfo = serviceProgressInfo;

            //
            Config = companyConfig;
        }
        public CompanyConfigDto CreateCompanyConfig(CreateCompanyConfigInput input)
        {
            var companyConfig = new CompanyConfig
            {
                Name = input.ConfigName,
                CompanyRefId = input.CompanyId,
                Value = input.ConfigValue,
                Type = input.ConfigDataType
            };

            //Saving entity with standard Insert method of repositories.
            int newCompanyConfigId = _companyConfigRepository.InsertAndGetId(companyConfig);

            return new CompanyConfigDto
            {
                Name = input.ConfigName,
                Value = input.ConfigValue,
                Type = input.ConfigDataType,
                Id = newCompanyConfigId
            };
        }
Exemple #6
0
        public override void RunCommissions(CompanyConfig config, RunQueueItem item, MakoAdmin makoAdmin, string connStr, QueueManagement queueManager)
        {
            try
            {
                //
                if (item.RunTy != 4)
                {
                    LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Info] Now Processing Real Time -  QueueId {item.QueueId}");
                }
                else
                {
                    LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Info] Now Processing Run -  QueueId {item.QueueId}");
                }

                //
                LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} RunTy({item.RunTy}), PlanId({item.QueueId}), RevisionId({item.RevisionId})");


                // Assembly assm, string typesXML, string bonusXML, string glossaryXML,
                // string overrideXML, string rankXML, string volumeXML
                var myschema = new MakoXMLSchemas(
                    makoAdmin.ProjectAssembly,
                    makoAdmin.ProjectAssembly.GetName().Name + ".MakoTypes.xml",
                    makoAdmin.ProjectAssembly.GetName().Name + ".MakoBonuses.xml",
                    "",
                    makoAdmin.ProjectAssembly.GetName().Name + ".MakoOverrides.xml",
                    makoAdmin.ProjectAssembly.GetName().Name + ".MakoRanks.xml",
                    makoAdmin.ProjectAssembly.GetName().Name + ".MakoVolumes.xml"
                    );

                MakoConfig comConfig = new MakoConfig()
                {
                    CompanyID = config.CompanyId,
                    PeriodID  = item.PeriodId,
                    PeriodTy  = item.PeriodTy,
                    QueueID   = item.QueueId,
                    RunDescr  = item.RunDescr,
                    RunID     = item.RunId,
                    RunTy     = item.RunTy,
                    XMLSchema = myschema,
                    PlanID    = item.PlanId,
                    RevisonID = item.RevisionId
                };

                LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow.ToString("G")} [Info] Commission complete");

                //
                makoAdmin.ProcessCommissions(comConfig);

                //
                if (comConfig.RunID != 0 && comConfig.RunTy != 4)
                {
                    LoggingHelpers.UpdateRunLog(connStr, config.CompanyId, item.QueueId, comConfig.RunID);
                }
                //
                queueManager.DeleteQueueItem(item.QueueId);
            }
            catch (AggregateException e)
            {
                //
                foreach (var ex in e.InnerExceptions)
                {
                    LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Error] " + ex.Message);
                    LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Error] " + ex.StackTrace);
                }
                //
                LoggingHelpers.LogQueueError(connStr, config.CompanyId, item, e);

#if DEVELOPMENT
#else
                Common.API.SendGrid.SendGridHelper.SendAlertAsync("Mako Runner Exception", $"Company {config.CompanyName}, RunTy {item.RunTy}, Description {item.RunDescr} {Environment.NewLine} {e}",
                                                                  $"Company {config.CompanyName}, RunTy {item.RunTy}, Description {item.RunDescr} {Environment.NewLine} {e}");
#endif

                throw;
            }
            catch (Exception ex)
            {
                //
                LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Error] " + ex.Message);
                LoggingHelpers.InsertIntoLog(connStr, config.CompanyId, item.QueueId, $"{DateTime.UtcNow:G} [Error] " + ex.StackTrace);

                //
                LoggingHelpers.LogQueueError(connStr, config.CompanyId, item, ex);

#if DEVELOPMENT
#else
                if (!_isDevelopment)
                {
                    Common.API.SendGrid.SendGridHelper.SendAlertAsync("Mako Runner Exception", $"Company {config.CompanyName}, RunTy {item.RunTy}, Description {item.RunDescr} {Environment.NewLine} {ex}",
                                                                      $"Company {config.CompanyName}, RunTy {item.RunTy}, Description {item.RunDescr} {Environment.NewLine} {ex}");
                }
#endif
                throw;
            }
        }
Exemple #7
0
 public new static void RunCommissionsStatic(CompanyConfig config, RunQueueItem item, MakoAdmin makoAdmin, string connStr, QueueManagement queueManager)
 {
 }
Exemple #8
0
 /// <summary>
 /// A placeholder for the method implemented in the derived classes.
 /// </summary>
 /// <param name="config"></param>
 /// <param name="item"></param>
 /// <param name="makoAdmin"></param>
 /// <param name="connStr"></param>
 /// <param name="queueManager"></param>
 /// <remarks>
 /// Derived classes must declare the RunCommissions as:
 ///		public override void RunCommissions(...)
 /// </remarks>
 public virtual void RunCommissions(CompanyConfig config, RunQueueItem item, MakoAdmin makoAdmin, string connStr, QueueManagement queueManager)
 {
     throw new NotImplementedException(
               "Error in RunCommissions. The method must have a new implementation in derived classes.");
 }
Exemple #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="companyConfig"></param>
 /// <param name="serviceProgressInfo"></param>
 public TopshelfWindowsService(CompanyConfig companyConfig, ServiceProgressInfo serviceProgressInfo) :
     base(companyConfig, serviceProgressInfo)
 {
 }
 public async Task <CompanyConfig> UpdateCompanyConfig(CompanyConfig CompanyConfigInfo)
 {
     return(await _repository.UpdateAsync(CompanyConfigInfo));
 }
        public async Task <CompanyConfig> CreateCompanyConfig(CompanyConfig CompanyConfigInfo)
        {
            CompanyConfigInfo.Id = await _repository.InsertAndGetIdAsync(CompanyConfigInfo);

            return(CompanyConfigInfo);
        }