Beispiel #1
0
        private static void ApproveDevicePendingApprovalCabster(string deviceId, string applicationName, string companyName)
        {
            Console.Write("Approving device pending approval for Figlut Cabster... ");
            DateTime licenseExpiryDate   = DateTime.Now.Add(new TimeSpan(365, 0, 0, 0));
            string   FiglutWebServiceURL = "http://184.22.83.112/Figlut.Web.Service/Service.asmx";
            ServiceFunctionResultOfListOfCustomer resultCustomer = GlobalDataCache.Instance.Service.GetCustomerByField(
                EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false),
                companyName,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (resultCustomer.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultCustomer.Message);
            }
            Customer customer = resultCustomer.Contents[0];
            ServiceProcedureResult approvalResult = GlobalDataCache.Instance.Service.ApproveDevicePendingApproval(
                deviceId,
                applicationName,
                null,
                null,
                FiglutWebServiceURL,
                365,
                customer,
                GlobalDataCache.Instance.CurrentUser);

            if (approvalResult.Code != ServiceResultCode.Success)
            {
                throw new Exception(approvalResult.Message);
            }
            Console.WriteLine("done");
        }
Beispiel #2
0
 private void mnuUpdateAdd_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtCompanyName.Text))
     {
         txtCompanyName.Focus();
         throw new UserThrownException("Company Name may not be left empty.", false, true, false);
     }
     if (_propertyValueExists(EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false), txtCompanyName.Text))
     {
         throw new UserThrownException(string.Format(
                                           "A customer with the Company Name {0} alreadpy exists.", txtCompanyName.Text), false, true, false);
     }
     _customer.CompanyName     = txtCompanyName.Text;
     _customer.PhysicalAddress = txtPhysicalAddress.Text;
     _customer.PostalAddress   = txtPostalAddress.Text;
     _customer.ContactName     = txtContactName.Text;
     _customer.ContactNumber   = txtContactNumber.Text;
     _customer.ContactEmail    = txtContactEmail.Text;
     if (_operation == EntityOperation.Add)
     {
         _customer.DateCreated = DateTime.Now;
     }
     this.DialogResult = DialogResult.OK;
     Close();
 }
Beispiel #3
0
        private void mnuEditDelete_Click(object sender, EventArgs e)
        {
            Nullable <Guid> selectedId = UIHelper.GetSelectedRowId(
                grdUsers,
                EntityReader <User> .GetPropertyName(p => p.UserId, true),
                true);

            if (_userCache[selectedId.Value].UserId == GlobalDataCache.Instance.CurrentUser.UserId)
            {
                throw new UserThrownException(
                          "May not delete current user. Please logon as different user to delete the selected user.",
                          false,
                          true,
                          false);
            }
            if (UIHelper.AskQuestion(
                    "Deleting a user will delete all the data associated with this user. Are you sure you want to delete the selected user?")
                != DialogResult.Yes)
            {
                return;
            }
            _userCache.Delete(selectedId.Value);
            Refresh(false);
            _unsavedChanges = true;
        }
Beispiel #4
0
        private static void SaveDeviceConfig()
        {
            Console.Write("Saving device config ... ");

            string   companyName       = "Monagham Farm";
            string   deviceId          = "RV2WJB270311-RV1WJB270515";
            DateTime licenseExpiryDate = DateTime.Now.Add(new TimeSpan(30, 0, 0, 0));
            ServiceFunctionResultOfListOfCustomer resultCustomer = GlobalDataCache.Instance.Service.GetCustomerByField(
                EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false),
                companyName,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (resultCustomer.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultCustomer.Message);
            }
            Customer customer = resultCustomer.Contents[0];

            ServiceFunctionResultOfListOfDeviceConfig resultDeviceConfigQuery = GlobalDataCache.Instance.Service.GetDeviceConfigByField(
                EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceId, false),
                deviceId,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (resultDeviceConfigQuery.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultDeviceConfigQuery.Message);
            }
            DeviceConfig deviceConfig = null;

            if (resultDeviceConfigQuery.Contents == null || resultDeviceConfigQuery.Contents.Length < 1)
            {
                deviceConfig = new DeviceConfig()
                {
                    DeviceConfigId = Guid.NewGuid(), DeviceId = deviceId, DateCreated = DateTime.Now
                };
            }
            else
            {
                deviceConfig = resultDeviceConfigQuery.Contents[0];
            }
            deviceConfig.ApplicationName                     = "CarTracker.Mobile.exe";
            deviceConfig.ApplicationWebServiceURL            = "http://169.254.2.2/CarTracker.Web.Service/Service.asmx";
            deviceConfig.ApplicationReplicationWebServiceURL = "http://169.254.2.2/CarTrackerMobileSync/sqlcesa35.dll";
            deviceConfig.ClientConfigWebServiceURL           = "http://169.254.2.2/Figlut.Web.Service/Service.asmx";
            deviceConfig.LicenseExpiryDate                   = licenseExpiryDate;
            deviceConfig.CustomerId = customer.CustomerId;

            ServiceProcedureResult resultDeviceConfig = GlobalDataCache.Instance.Service.SaveDeviceConfig(
                new DeviceConfig[] { deviceConfig },
                GlobalDataCache.Instance.CurrentUser,
                false);

            if (resultDeviceConfig.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultDeviceConfig.Message);
            }
            Console.WriteLine("done.");
        }
 public ActionResult Login(User model)
 {
     try
     {
         if (Request.IsAuthenticated)
         {
             return(RedirectToHome());
         }
         if (string.IsNullOrEmpty(model.UserName))
         {
             return(GetJsonResult(false, string.Format("{0} not entered.", EntityReader <User> .GetPropertyName(p => p.UserName, true))));
         }
         BcEntityContext context = BcEntityContext.Create();
         User            user    = context.Login(model.UserName, model.Password);
         if (user == null)
         {
             return(GetJsonResult(false, "Invalid user name or password."));
         }
         FormsAuthentication.SetAuthCookie(user.UserName, true);
         return(GetJsonResult(true));
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex);
         return(RedirectToError(ex.Message));
     }
 }
Beispiel #6
0
        private static void ApproveDevicePendingApprovalTripInspection(string deviceId, string applicationName, string companyName)
        {
            Console.Write("Approving device pending approval for Trip Inspection... ");
            string applicationWebServiceURL            = "http://www.r2mslive.co.za/R2MSWebService/BulkUpload.asmx";
            string applicationReplicationWebServiceURL = "http://41.86.108.77/CarTrackerMobileSync/sqlcesa35.dll";
            string FiglutWebServiceURL = "http://184.22.83.112/Figlut.Web.Service/Service.asmx";
            ServiceFunctionResultOfListOfCustomer resultCustomer = GlobalDataCache.Instance.Service.GetCustomerByField(
                EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false),
                companyName,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (resultCustomer.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultCustomer.Message);
            }
            Customer customer = resultCustomer.Contents[0];
            ServiceProcedureResult approvalResult = GlobalDataCache.Instance.Service.ApproveDevicePendingApproval(
                deviceId,
                applicationName,
                applicationWebServiceURL,
                applicationReplicationWebServiceURL,
                FiglutWebServiceURL,
                30,
                customer,
                GlobalDataCache.Instance.CurrentUser);

            if (approvalResult.Code != ServiceResultCode.Success)
            {
                throw new Exception(approvalResult.Message);
            }
            Console.WriteLine("done");
        }
Beispiel #7
0
 public bool IsValid(out string errorMessage)
 {
     errorMessage = null;
     if (string.IsNullOrEmpty(this.UserName))
     {
         errorMessage = string.Format("{0} not entered.", EntityReader <RegisterModel> .GetPropertyName(p => p.UserName, true));
     }
     else if (string.IsNullOrEmpty(this.Password))
     {
         errorMessage = string.Format("{0} not entered.", EntityReader <RegisterModel> .GetPropertyName(p => p.Password, true));
     }
     else if (string.IsNullOrEmpty(this.ConfirmPassword))
     {
         errorMessage = string.Format("{0} not entered.", EntityReader <RegisterModel> .GetPropertyName(p => p.ConfirmPassword, true));
         return(false);
     }
     else if (this.Password != this.ConfirmPassword)
     {
         errorMessage = string.Format("{0} and {1} do not match.",
                                      EntityReader <RegisterModel> .GetPropertyName(p => p.Password, true),
                                      EntityReader <RegisterModel> .GetPropertyName(p => p.ConfirmPassword, true));
     }
     else if (string.IsNullOrEmpty(this.EmailAddress))
     {
         errorMessage = string.Format("{0} not entered.", EntityReader <RegisterModel> .GetPropertyName(p => p.EmailAddress, true));
     }
     return(string.IsNullOrEmpty(errorMessage));
 }
 public bool RegisterUser(User user, out string errorMessage)
 {
     errorMessage = null;
     using (TransactionScope t = new TransactionScope())
     {
         User originalUser = GetUser(user.UserName, false, false);
         if (originalUser != null)
         {
             errorMessage = string.Format("{0} with {1} of '{2}' already exists.",
                                          typeof(User).Name,
                                          EntityReader <User> .GetPropertyName(p => p.UserName, true),
                                          user.UserName);
             return(false);
         }
         originalUser = GetUserByEmailAddress(user.EmailAddress, false, false);
         if (originalUser != null)
         {
             errorMessage = string.Format("{0} with {1} of '{2}' already exists.",
                                          typeof(User).Name,
                                          EntityReader <User> .GetPropertyName(p => p.EmailAddress, true),
                                          user.EmailAddress);
             return(false);
         }
         DB.GetTable <User>().InsertOnSubmit(user);
         DB.SubmitChanges();
         t.Complete();
     }
     return(true);
 }
Beispiel #9
0
 private void InitHiddenColumns()
 {
     _hiddenColumns = new List <string>();
     _hiddenColumns.Add(EntityReader <User> .GetPropertyName(p => p.UserId, true));
     _hiddenColumns.Add(EntityReader <User> .GetPropertyName(p => p.Password, true));
     _hiddenColumns.Add(EntityReader <User> .GetPropertyName(p => p.RoleId, true));
     _hiddenColumns.Add(EntityReader <User> .GetPropertyName(p => p.UserPermissionCache, true));
 }
Beispiel #10
0
        public Nullable <Guid> GetSelectedRowId()
        {
            if (grdDeviceConfigs.SelectedRows.Count < 1)
            {
                return(null);
            }
            DataRow row = ((DataRowView)(grdDeviceConfigs.SelectedRows[0].DataBoundItem)).Row;

            return(new Guid(row[EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceConfigId, true)].ToString()));
        }
        private void mnuEditDelete_Click(object sender, EventArgs e)
        {
            Nullable <Guid> selectedId = UIHelper.GetSelectedRowId(
                grdDevicesPendingApproval,
                EntityReader <DevicePendingApproval> .GetPropertyName(p => p.DevicePendingApprovalId, true),
                true);

            _devicePendingApprovalCache.Delete(selectedId.Value);
            Refresh(false);
            _unsavedChanges = true;
        }
        private void mnuEditApprove_Click(object sender, EventArgs e)
        {
            Nullable <Guid> selectedId = UIHelper.GetSelectedRowId(
                grdDevicesPendingApproval,
                EntityReader <DevicePendingApproval> .GetPropertyName(p => p.DevicePendingApprovalId, true),
                true);
            DevicePendingApproval devicePendingApproval = _devicePendingApprovalCache[selectedId.Value];

            using (ApproveDeviceForm f = new ApproveDeviceForm(devicePendingApproval))
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Refresh(true);
                }
            }
        }
        public bool RefreshFromServer(Guid aplexDataTableId)
        {
            ServiceFunctionResultOfListOfAplexDataColumn result = GlobalDataCache.Instance.Service.GetAplexDataColumnByField(
                EntityReader <AplexDataColumn> .GetPropertyName(p => p.AplexDataTableId, false),
                aplexDataTableId,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (ServiceResultHandler.HandleServiceResult(result))
            {
                return(true);
            }
            Clear();
            result.Contents.ToList().ForEach(p => _entities.Add(p.AplexDataColumnId, p));
            return(false);
        }
        public PublicHoliday GetPublicHoliday(Guid publicHolidayId, bool throwExceptionOnNotFound)
        {
            List <PublicHoliday> queryResult = (from p in DB.GetTable <PublicHoliday>()
                                                where p.PublicHolidayId == publicHolidayId
                                                select p).ToList();
            PublicHoliday result = queryResult.Count < 1 ? null : queryResult.First();

            if (result == null && throwExceptionOnNotFound)
            {
                throw new ArgumentNullException(string.Format("Could not find {0} with {1} of {2}.",
                                                              typeof(PublicHoliday).Name,
                                                              EntityReader <PublicHoliday> .GetPropertyName(p => p.PublicHolidayId, false),
                                                              publicHolidayId));
            }
            return(result);
        }
Beispiel #15
0
        private static void ApproveDevicePendingApprovalVisitUs(string deviceId, string applicationName, string companyName)
        {
            Console.Write("Approving device pending approval for Visit Us... ");
            //string applicationWebServiceURL = "http://41.86.108.77/PebbleRock.CarTracker.Web.Service/Service.asmx";
            //string applicationReplicationWebServiceURL = "http://41.86.108.77/PebbleRockMobileSync/sqlcesa35.dll";
            //string applicationWebServiceURL = "http://41.86.108.77/Caribbean.CarTracker.Web.Service/Service.asmx";
            //string applicationReplicationWebServiceURL = "http://41.86.108.77/CaribbeanRockMobileSync/sqlcesa35.dll";

            //string applicationWebServiceURL = "http://41.86.108.77/Monaghan.VisitUs.Web.Service/Service.asmx";
            //string applicationReplicationWebServiceURL = null;
            //string FiglutWebServiceURL = "http://41.76.214.230/Figlut.Web.Service/Service.asmx";

            //string applicationWebServiceURL = "http://41.86.108.77/EcoPark.CarTracker.Web.Service/Service.asmx";
            //string applicationReplicationWebServiceURL = "http://41.86.108.77/EcoPark.CarTracker.Web.Service/SyncService.svc";
            //string FiglutWebServiceURL = "http://184.22.83.112/Figlut.Web.Service/Service.asmx";

            string applicationWebServiceURL            = "http://41.86.108.77/Dainfern.CarTracker.Web.Service/Service.asmx";
            string applicationReplicationWebServiceURL = "http://41.86.108.77/Dainfern.CarTracker.Web.Service/SyncService.svc";
            string FiglutWebServiceURL = "http://41.76.214.230/Figlut.Web.Service/Service.asmx";

            ServiceFunctionResultOfListOfCustomer resultCustomer = GlobalDataCache.Instance.Service.GetCustomerByField(
                EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false),
                companyName,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (resultCustomer.Code != ServiceResultCode.Success)
            {
                throw new Exception(resultCustomer.Message);
            }
            Customer customer = resultCustomer.Contents[0];
            ServiceProcedureResult approvalResult = GlobalDataCache.Instance.Service.ApproveDevicePendingApproval(
                deviceId,
                applicationName,
                applicationWebServiceURL,
                applicationReplicationWebServiceURL,
                FiglutWebServiceURL,
                730,
                customer,
                GlobalDataCache.Instance.CurrentUser);

            if (approvalResult.Code != ServiceResultCode.Success)
            {
                throw new Exception(approvalResult.Message);
            }
            Console.WriteLine("done");
        }
Beispiel #16
0
 public void RefreshGrid(Guid idToSelect)
 {
     RefreshGrid();
     foreach (DataGridViewRow r in grdDeviceConfigs.Rows)
     {
         r.Selected = false;
     }
     foreach (DataGridViewRow r in grdDeviceConfigs.Rows)
     {
         DataRow drv       = ((DataRowView)(r.DataBoundItem)).Row;
         Guid    currentId = new Guid(drv[EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceConfigId, true)].ToString());
         if (currentId == idToSelect)
         {
             r.Selected = true;
             return;
         }
     }
 }
Beispiel #17
0
        private void mnuEditDelete_Click(object sender, EventArgs e)
        {
            Nullable <Guid> selectedId = UIHelper.GetSelectedRowId(
                grdCustomers,
                EntityReader <Customer> .GetPropertyName(p => p.CustomerId, true),
                true);
            Customer customer = _customerCache[selectedId.Value];

            if (UIHelper.AskQuestion(
                    "Deleting a customer will delete all the data associated with this customer. Are you sure you want to delete the selected customer?")
                != DialogResult.Yes)
            {
                return;
            }
            _customerCache.Delete(selectedId.Value);
            Refresh(false);
            _unsavedChanges = true;
        }
        public User GetUser(Guid userId, bool throwExceptionOnNotFound)
        {
            List <User> queryResult = (from u in DB.GetTable <User>()
                                       where u.UserId == userId
                                       orderby u.UserName
                                       select u).ToList();
            User result = queryResult.Count < 1 ? null : queryResult.First();

            if (throwExceptionOnNotFound && result == null)
            {
                throw new NullReferenceException(string.Format(
                                                     "Could not find {0} with {1} of '{2}'.",
                                                     typeof(User).Name,
                                                     EntityReader <User> .GetPropertyName(p => p.UserId, false),
                                                     userId.ToString()));
            }
            return(result);
        }
Beispiel #19
0
        public void RefreshGrid()
        {
            string originalStatus = Status;

            try
            {
                int selectedRowIndex = -1;
                if (grdDeviceConfigs.SelectedRows.Count > 0)
                {
                    selectedRowIndex = grdDeviceConfigs.SelectedRows[0].Index;
                }
                if (_filtersEnabled)
                {
                    Dictionary <string, object> properties = new Dictionary <string, object>();
                    properties.Add(EntityReader <DeviceConfig> .GetPropertyName(p => p.DeviceId, false), txtFilterDeviceId.Text);
                    properties.Add(EntityReader <DeviceConfig> .GetPropertyName(p => p.ApplicationName, false), txtFilterApplicationName.Text);
                    grdDeviceConfigs.DataSource = _deviceConfigCache.GetDataTable(
                        properties,
                        false,
                        true,
                        chkFilterExpired.Checked,
                        _filteredDeviceConfigCache); //After this call the filtered cache will only contain the items included while the filtered was applied.
                }
                else
                {
                    grdDeviceConfigs.DataSource = _deviceConfigCache.GetDataTable(null, false, true);
                    _filteredDeviceConfigCache.Clear();
                    _deviceConfigCache.ToList().ForEach(p => _filteredDeviceConfigCache.Add(p));
                }
                _hiddenColumns.ForEach(c => grdDeviceConfigs.Columns[c].Visible = false);
                if (selectedRowIndex < grdDeviceConfigs.Rows.Count && selectedRowIndex > -1)
                {
                    grdDeviceConfigs.Rows[selectedRowIndex].Selected = true;
                }
                grdDeviceConfigs.Refresh();
            }
            finally
            {
                if (Status != originalStatus)
                {
                    Status = originalStatus;
                }
            }
        }
        public PublicHoliday GetPublicHoliday(string countryCode, string dateIdentifier, bool throwExceptionOnNotFound)
        {
            string countryCodeLower          = countryCode.ToLower();
            List <PublicHoliday> queryResult = (from p in DB.GetTable <PublicHoliday>()
                                                where p.CountryCode == countryCodeLower && p.DateIdentifier == dateIdentifier
                                                select p).ToList();
            PublicHoliday result = queryResult.Count < 1 ? null : queryResult.First();

            if (result == null && throwExceptionOnNotFound)
            {
                throw new ArgumentNullException(string.Format("Could not find {0} with {1} of {2} and {3} of {4}.",
                                                              typeof(PublicHoliday).Name,
                                                              EntityReader <PublicHoliday> .GetPropertyName(p => p.CountryCode, false),
                                                              countryCode,
                                                              EntityReader <PublicHoliday> .GetPropertyName(p => p.DateIdentifier, false),
                                                              dateIdentifier));
            }
            return(result);
        }
        public User GetUser(string userName, bool caseSensitive, bool throwExceptionOnNotFound)
        {
            string      userNameToSearch = caseSensitive ? userName : userName.Trim().ToLower();
            List <User> queryResult      = (from u in DB.GetTable <User>()
                                            where u.UserName.ToLower() == userNameToSearch
                                            orderby u.UserName
                                            select u).ToList();
            User result = queryResult.Count < 1 ? null : queryResult.First();

            if (throwExceptionOnNotFound && result == null)
            {
                throw new NullReferenceException(string.Format(
                                                     "Could not find {0} with {1} of '{2}'.",
                                                     typeof(User).Name,
                                                     EntityReader <User> .GetPropertyName(p => p.UserName, false),
                                                     userNameToSearch));
            }
            return(result);
        }
        private void Refresh(bool fromServer)
        {
            string originalStatus = Status;

            try
            {
                if ((_unsavedChanges) && (fromServer) &&
                    (UIHelper.AskQuestion("There are unsaved changes. Are you sure you want to refresh from server. All unsaved changes will be lost.") !=
                     DialogResult.Yes))
                {
                    return;
                }
                using (WaitCursor w = new WaitCursor())
                {
                    if (fromServer)
                    {
                        Status = "Refreshing from server ...";
                        if (_deviceConfigActionCache.RefreshFromServerByFilters(
                                string.Empty, string.Empty,
                                _startDate,
                                _endDate))
                        {
                            return;
                        }
                        _unsavedChanges = false;
                    }
                    int index = UIHelper.GetSelectedGridRowIndex(grdDeviceConfigActions);
                    Dictionary <string, object> properties = new Dictionary <string, object>();
                    properties.Add(EntityReader <DeviceConfigAction> .GetPropertyName(p => p.DeviceId, false), txtDeviceId.Text);
                    grdDeviceConfigActions.DataSource = _deviceConfigActionCache.GetDataTable(properties, false, true);
                    _hiddenColumns.ForEach(p => grdDeviceConfigActions.Columns[p].Visible = false);
                    UIHelper.SelectGridRow(grdDeviceConfigActions, index);
                }
            }
            finally
            {
                if (Status != originalStatus)
                {
                    Status = originalStatus;
                }
            }
        }
Beispiel #23
0
        private void mnuEditUpdate_Click(object sender, EventArgs e)
        {
            Nullable <Guid> selectedId = UIHelper.GetSelectedRowId(
                grdCustomers,
                EntityReader <Customer> .GetPropertyName(p => p.CustomerId, true),
                true);
            Customer customer = _customerCache[selectedId.Value];

            using (CustomerForm f = new CustomerForm(
                       customer,
                       EntityOperation.Update,
                       new PropertyValueExists(_customerCache.PropertyValueExists)))
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Refresh(false);
                    _unsavedChanges = true;
                }
            }
        }
Beispiel #24
0
        private static void ImportICalendarFiles()
        {
            BcServiceApp.Instance.Initialize(false);
            BcEntityContext context = BcEntityContext.Create();

            foreach (CountryCalendarImportInfo c in BcServiceApp.Instance.Settings.CountryCalendarImportDirectories)
            {
                if (string.IsNullOrEmpty(c.CountryCode) || string.IsNullOrEmpty(c.CountryName))
                {
                    throw new NullReferenceException(string.Format("{0} or {1} not specified on {2} in {3}.",
                                                                   EntityReader <CountryCalendarImportInfo> .GetPropertyName(p => p.CountryCode, false),
                                                                   EntityReader <CountryCalendarImportInfo> .GetPropertyName(p => p.CountryName, false),
                                                                   typeof(CountryCalendarImportInfo).Name,
                                                                   BcServiceApp.Instance.Settings.FilePath));
                }
                if (!Directory.Exists(c.ICalendarImportDirectory))
                {
                    throw new DirectoryNotFoundException(string.Format("Could not find directory {0} for country {1} ({2}).",
                                                                       c.ICalendarImportDirectory,
                                                                       c.CountryCode,
                                                                       c.CountryName));
                }
                string[] filePaths = Directory.GetFiles(c.ICalendarImportDirectory, "*.ics");
                foreach (string f in filePaths)
                {
                    GOC.Instance.Logger.LogMessage(new LogMessage(string.Format("Parsing iCalendar file: {0} ...", f), LogMessageType.Information, LoggingLevel.Normal));
                    ICalCalendar calendar = ICalPublicHolidayParser.ParseICalendarFile(f, c.CountryCode, c.CountryName);

                    GOC.Instance.Logger.LogMessage(new LogMessage(string.Format("Saving iCalendar to DB: {0} ...", f), LogMessageType.Information, LoggingLevel.Normal));
                    context.SaveICalCalendar(calendar);

                    if (BcServiceApp.Instance.Settings.DeleteICalendarFilesAfterImport)
                    {
                        GOC.Instance.Logger.LogMessage(new LogMessage(string.Format("Deleting iCalendar file: {0} ...", f), LogMessageType.Information, LoggingLevel.Normal));
                        File.Delete(f);
                    }

                    GOC.Instance.Logger.LogMessage(new LogMessage(string.Format("Completed iCalendar file import: {0} ...", f), LogMessageType.SuccessAudit, LoggingLevel.Minimum));
                }
            }
        }
        private void Refresh(bool fromServer)
        {
            string originalStatus = Status;

            try
            {
                using (WaitCursor w = new WaitCursor())
                {
                    if (fromServer)
                    {
                        Status = "Refreshing from server ...";
                        if (_customerCache.RefreshFromServer())
                        {
                            return;
                        }
                    }
                    int index = lstCustomers.SelectedIndex;
                    Dictionary <string, object> properties = new Dictionary <string, object>();
                    properties.Add(EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false), txtCompanyName.Text);
                    List <Customer> customers = _customerCache.GetEntitiesByProperties(properties, false);
                    lstCustomers.Items.Clear();
                    customers.ForEach(p => lstCustomers.Items.Add(p));
                    if (index < lstCustomers.Items.Count)
                    {
                        lstCustomers.SelectedIndex = index;
                    }
                    else if (lstCustomers.Items.Count > 0)
                    {
                        lstCustomers.SelectedIndex = 0;
                    }
                }
            }
            finally
            {
                if (Status != originalStatus)
                {
                    Status = originalStatus;
                }
            }
        }
Beispiel #26
0
        private void Refresh(bool fromServer)
        {
            string originalStatus = Status;

            try
            {
                if ((_unsavedChanges) && (fromServer) &&
                    (UIHelper.AskQuestion("There are unsaved changes. Are you sure you want to refresh from server. All unsaved changes will be lost.") !=
                     DialogResult.Yes))
                {
                    return;
                }
                using (WaitCursor w = new WaitCursor())
                {
                    if (fromServer)
                    {
                        Status = "Refreshing from server ...";
                        if (_userCache.RefreshFromServerWithPermissions())
                        {
                            return;
                        }
                        _unsavedChanges = false;
                    }
                    int index = UIHelper.GetSelectedGridRowIndex(grdUsers);
                    Dictionary <string, object> properties = new Dictionary <string, object>();
                    properties.Add(EntityReader <User> .GetPropertyName(p => p.UserName, false), txtUserName.Text);
                    grdUsers.DataSource = _userCache.GetDataTable(properties, false, true);
                    _hiddenColumns.ForEach(c => grdUsers.Columns[c].Visible = false);
                    UIHelper.SelectGridRow(grdUsers, index);
                }
            }
            finally
            {
                if (Status != originalStatus)
                {
                    Status = originalStatus;
                }
            }
        }
        public bool RefreshFromServer(Guid aplexId, bool refreshScreenFields)
        {
            ServiceFunctionResultOfListOfAplexScreen result = GlobalDataCache.Instance.Service.GetAplexScreenByField(
                EntityReader <AplexScreen> .GetPropertyName(p => p.AplexId, false),
                aplexId,
                false,
                GlobalDataCache.Instance.CurrentUser);

            if (ServiceResultHandler.HandleServiceResult(result))
            {
                return(true);
            }
            Clear();
            result.Contents.ToList().ForEach(p => _entities.Add(p.AplexScreenId, p));
            if (refreshScreenFields)
            {
                foreach (AplexScreen s in this)
                {
                    s.AplexScreenFieldCache.RefreshFromServer(s.AplexScreenId);
                }
            }
            return(false);
        }
Beispiel #28
0
 private void InitHiddenColumns()
 {
     _hiddenColumns = new List <string>();
     _hiddenColumns.Add(EntityReader <ServerError> .GetPropertyName(p => p.ServerErrorCacheId, true));
 }
 private void InitHiddenColumns()
 {
     _hiddenColumns = new List <string>();
     _hiddenColumns.Add(EntityReader <DeviceConfigAction> .GetPropertyName(p => p.DeviceConfigActionId, true));
     _hiddenColumns.Add(EntityReader <DeviceConfigAction> .GetPropertyName(p => p.DeviceConfigId, true));
 }
Beispiel #30
0
 private void InitHiddenColumns()
 {
     _hiddenColumns = new List <string>();
     _hiddenColumns.Add(EntityReader <Customer> .GetPropertyName(p => p.CustomerId, true));
 }