public ConfigurationBO GetConfiguration(int TenantID, string ConfigName) { ConfigurationBO actBO = new ConfigurationBO(); using (SqlConnection con = new SqlConnection(Constant.DBConnectionString)) { SqlCommand cmd = new SqlCommand("select * from stblConfigSettings where TenantID = @TenantID and ConfigName = @ConfigName", con); { cmd.Parameters.Add(new SqlParameter("@TenantID", TenantID)); cmd.Parameters.Add(new SqlParameter("@ConfigName", ConfigName)); cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { actBO.ConfigID = reader["ConfigID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["ConfigID"]); actBO.ConfigType = reader["ConfigType"] == DBNull.Value ? string.Empty : Convert.ToString(reader["ConfigType"]); actBO.ConfigName = reader["ConfigName"] == DBNull.Value ? string.Empty : Convert.ToString(reader["ConfigName"]); actBO.ConfigValue = reader["ConfigValue"] == DBNull.Value ? string.Empty : Convert.ToString(reader["ConfigValue"]); actBO.TenantID = reader["TenantID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["TenantID"]); actBO.PrefixYear = reader["PrefixYear"] == DBNull.Value ? 0 : Convert.ToInt32(reader["PrefixYear"]); actBO.SrNumber = reader["SrNumber"] == DBNull.Value ? 0 : Convert.ToInt32(reader["SrNumber"]); } } reader.Close(); con.Close(); } } return(actBO); }
public int SaveConfig(ConfigurationBO configurationBO) { int rtnvalue = 0; using (SqlConnection con = new SqlConnection(Common.Constant.DBConnectionString)) { using (SqlCommand cmd = new SqlCommand("sspSaveConfig")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@TenantID", configurationBO.TenantID)); cmd.Parameters.Add(new SqlParameter("@ConfigValue", configurationBO.ConfigValue)); cmd.Parameters.Add(new SqlParameter("@ConfigName", configurationBO.ConfigName)); cmd.Parameters.Add(new SqlParameter("@ConfigType", configurationBO.ConfigType)); cmd.Parameters.Add(new SqlParameter("@PrefixYear", configurationBO.PrefixYear)); cmd.Parameters.Add(new SqlParameter("@ConfigID", configurationBO.ConfigID)); cmd.Parameters.Add(new SqlParameter("@SrNumber", configurationBO.SrNumber)); con.Open(); rtnvalue = cmd.ExecuteNonQuery(); con.Close(); } } return(rtnvalue); }
private void ConfigurationForm_Load(object sender, EventArgs e) { string checkboxmsg = "If you check this feature then the program will start watching \n" + "the directories that you already have entered in the program immediately \n" + "following the program starting. If it is unchecked, then the program waits for \n" + "you to start it manually."; toolTip1.SetToolTip(cboxAutoStartCopyingFiles, checkboxmsg); string timermsg = "As your computer changes files it goes through several steps. \n" + "Each of those steps can trigger the copying mechanism. For efficiency purposes,\n" + "it is better to wait some time before attempting to copy a file, just in case it \n" + "is about to be changed again. If you are mostly changing small files, testing \n" + "has shown 3 seconds to be the best. Alternatively, If you are changing large \n" + "files a longer wait period is highly recommended."; toolTip1.SetToolTip(txtTimerLength, timermsg); toolTip1.SetToolTip(lblTimerLength, timermsg); string retrycntmsg = "Each time a file changes an attempt to copy that file is \n" + "made (after waiting the appropriate time as marked above). If that copy fails \n" + "for some reason, attempts will be made repeatedly until the file is either \n" + "copied or the limit entered here is reached."; toolTip1.SetToolTip(txtMaximumRetryCount, retrycntmsg); toolTip1.SetToolTip(lblMaximumRetryCount, retrycntmsg); ConfigurationBO bo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); cboxAutoStartCopyingFiles.Checked = bo.CContainer.AutoStart; txtMaximumRetryCount.Text = bo.CContainer.MaxRetryCount.ToString(); txtTimerLength.Text = bo.CContainer.WaitTime.ToString(); }
public override bool Delete(params object[] keys) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.SliderConnection.StartTransaction(IsolationLevel.ReadUncommitted); var configurationBo = new ConfigurationBO(); var sliderBo = new SliderBO(); var obj = sliderBo.Get(this.ConnectionHandler, keys); var config = configurationBo.Get(this.ConnectionHandler, obj.WebId); if (config == null) { return(false); } if (config.BigSlideId == obj.SlideId) { config.BigSlideId = null; } if (config.AverageSlideId == obj.SlideId) { config.AverageSlideId = null; } if (config.MiniSlideId == obj.SlideId) { config.MiniSlideId = null; } if (!configurationBo.Update(this.ConnectionHandler, config)) { throw new Exception("خطایی درذخیره تنظیمات وجود دارد"); } if (!sliderBo.Delete(this.ConnectionHandler, obj.WebId, obj.SlideId)) { throw new Exception("خطایی در حذف اسلاید وجود دارد"); } if (!SliderComponent.Instance.SlideTransactionalFacade(this.GalleryConnection).Delete(obj.SlideId)) { return(false); } this.ConnectionHandler.CommitTransaction(); this.SliderConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); throw new KnownException(ex.Message, ex); } }
private void Save() { ConfigurationBO bo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); ConfigurationContainer container = bo.CContainer; container.AutoStart = cboxAutoStartCopyingFiles.Checked; container.MaxRetryCount = Int32.Parse(txtMaximumRetryCount.Text); container.WaitTime = Int32.Parse(txtTimerLength.Text); bo.Save(); }
public override bool Delete(CongressSlide obj) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.SliderConnection.StartTransaction(IsolationLevel.ReadUncommitted); var configurationBo = new ConfigurationBO(); var config = configurationBo.ValidConfig(this.ConnectionHandler, obj.CongressId); if (config.BigSlideId == obj.SlideId) { config.BigSlideId = null; } if (config.AverageSlideId == obj.SlideId) { config.AverageSlideId = null; } if (config.MiniSlideId == obj.SlideId) { config.MiniSlideId = null; } if (!configurationBo.Update(this.ConnectionHandler, config)) { throw new Exception(Resources.Congress.ErrorInEditConfuguration); } if (!new CongressSlideBO().Delete(this.ConnectionHandler, obj)) { throw new Exception("خطایی در حذف اسلاید وجود دارد"); } if (!SliderComponent.Instance.SlideTransactionalFacade(this.GalleryConnection).Delete(obj.SlideId)) { return(false); } this.ConnectionHandler.CommitTransaction(); this.SliderConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
private void btnMMExit_Click(object sender, EventArgs e) { ListenerBO bo = (ListenerBO)SingletonManager.GetSingleton(typeof(ListenerBO)); bo.StopListeners(); JobsBO jbo = (JobsBO)SingletonManager.GetSingleton(typeof(JobsBO)); jbo.Save(); ConfigurationBO cbo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); cbo.Save(); //this.Close(); Application.Exit(); }
private void WriteLog(ActionReportContainer container) { ConfigurationBO cbo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); string logfile = SharedBO.GetLogFile(); StreamWriter sw = null; FileInfo fi = new FileInfo(logfile); lock (this.SyncRoot) { try { sw = fi.AppendText(); if (container.OriginalPath.CompareTo("") != 0) { sw.WriteLine("File: \t\t" + container.OriginalPath); } if (container.CopyPath.CompareTo("") != 0) { sw.WriteLine("Copy to:\t" + container.CopyPath); } sw.WriteLine("Action: \t\t" + container.Action.ToString()); sw.WriteLine("Result: \t\t" + container.ActionResult.ToString()); sw.WriteLine("Comment:\t" + container.ActionResultDescription); sw.WriteLine("Occured at:\t" + container.OccuredAt.ToString("f")); sw.Flush(); } catch (Exception) { //TODO: IReporter.FirstReporter.WriteLog() //System.Windows.Forms.Form eForm = new LlamaCarbonCopy.Controls.Forms.ErrorMessageForm( // String.Format( // OBBO.blah(), // logfile), // OBBO.err() // ); //eForm.ShowDialog(); } finally { if (sw != null) { sw.Close(); } } } }
public bool Update(Configuration configuration, HttpPostedFileBase favIcon) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection); var configurationBo = new ConfigurationBO(); if (favIcon != null) { if (configuration.FavIcon == null) { configuration.FavIcon = fileTransactionalFacade.Insert(favIcon); } else { if (!fileTransactionalFacade.Update(favIcon, (Guid)configuration.FavIcon)) { throw new Exception("خطا در ذخیره fav icon وجود دارد"); } } } if (!configurationBo.Update(this.ConnectionHandler, configuration)) { throw new Exception("خطای در ذخیره اطلاعات رخ داده است"); } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public ConfigurationBO UpdateActiveClient(int TenantID, string ConfigValue) { ConfigurationBO ActiveupdateBO = new ConfigurationBO(); using (SqlConnection con = new SqlConnection(Constant.DBConnectionString)) { SqlCommand cmd = new SqlCommand("update stblConfigSettings set ConfigValue = @ConfigValue where TenantID = @TenantID and ConfigName = 'ActiveClients'", con); { cmd.Parameters.Add(new SqlParameter("@TenantID", TenantID)); cmd.Parameters.Add(new SqlParameter("@ConfigValue", ConfigValue)); cmd.CommandType = CommandType.Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } return(ActiveupdateBO); }
private void Form1_Load(object sender, EventArgs e) { VersionBO vbo = (VersionBO)SingletonManager.GetSingleton(typeof(VersionBO)); this.Text = vbo.ProgramName + " v" + vbo.Version; LoadJobs(); //RefreshFiles(); ConfigurationBO bo = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); ListenerBO lbo = (ListenerBO)SingletonManager.GetSingleton(typeof(ListenerBO)); if (bo.CContainer.AutoStart) { lbo.StartListeners(); } lbo.StatusChanged += new EventHandler(lbo_StatusChanged); lbo_StatusChanged(lbo, EventArgs.Empty); SynchronizeBO sbo = (SynchronizeBO)SingletonManager.GetSingleton(typeof(SynchronizeBO)); sbo.Synchronized += new SynchEventHandler(sbo_Synchronized); sbo.FinishedSynch += new EventHandler(sbo_FinishedSynch); }
public ConfigurationBO SaveActiveClient(int TenantID, string ConfigValue) { ConfigurationBO ActivesaveBO = new ConfigurationBO(); using (SqlConnection con = new SqlConnection(Constant.DBConnectionString)) { int year = Convert.ToInt32(DateTime.Now.Year.ToString()); SqlCommand cmd = new SqlCommand("insert into stblConfigSettings(ConfigType,ConfigName,ConfigValue,TenantID,PrefixYear) values('ActiveUsers', 'ActiveClients', @ConfigValue, @TenantID, @Year)", con); { cmd.Parameters.Add(new SqlParameter("@TenantID", TenantID)); cmd.Parameters.Add(new SqlParameter("@ConfigValue", ConfigValue)); cmd.Parameters.Add(new SqlParameter("@Year", year)); cmd.CommandType = CommandType.Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } return(ActivesaveBO); }
public ModelView.UserCardModel SearchChipFoodReport(Guid chipfoodId, Guid userId) { try { var userCardModels = new ModelView.UserCardModel(); var userBo = new UserBO(); var user = userBo.Get(this.ConnectionHandler, userId); var config = new ConfigurationBO().Get(this.ConnectionHandler, user.CongressId); var configcontent = new ConfigurationContentBO().Get(this.ConnectionHandler, user.CongressId, config.CardLanguageId); var homa = new HomaBO().Get(this.ConnectionHandler, user.CongressId); var chipsFoodUserBo = new ChipsFoodUserBO(); var chipsFoodUsers = chipsFoodUserBo.Get(this.ConnectionHandler, chipfoodId, user.Id); var chipsFoodBo = new ChipsFoodBO(); if (chipsFoodUsers != null) { var chipsFood = chipsFoodBo.Get(this.ConnectionHandler, chipsFoodUsers.ChipsFoodId); var cardModels = userBo.GetChipFootUser(this.ConnectionHandler, user, configcontent, homa, new List <ChipsFood> { chipsFood }); if (cardModels.Count > 0) { userCardModels = cardModels.FirstOrDefault(); } } return(userCardModels); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool Update(Configuration configuration, ConfigurationContent configurationContent, HttpPostedFileBase refreeAttachment, HttpPostedFileBase boothMapAttachmentId, HttpPostedFileBase orginalPoster, HttpPostedFileBase miniPoster, HttpPostedFileBase logo, HttpPostedFileBase header, HttpPostedFileBase footer, HttpPostedFileBase hallMapId, HttpPostedFileBase backgroundImageId, HttpPostedFileBase favIcon, string modelName, List <DiscountTypeSection> sectiontypes) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.ContentManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); this.PaymentConnection.StartTransaction(IsolationLevel.ReadUncommitted); var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection); var configurationBo = new ConfigurationBO(); var oldconfig = configurationBo.Get(this.ConnectionHandler, configuration.CongressId); configuration.TerminalPassword = !String.IsNullOrEmpty(configuration.TerminalPassword) ? StringUtils.Encrypt(configuration.TerminalPassword) : oldconfig.TerminalPassword; configuration.SMSAccountPassword = !String.IsNullOrEmpty(configuration.SMSAccountPassword) ? StringUtils.Encrypt(configuration.SMSAccountPassword) : oldconfig.SMSAccountPassword; configuration.MailPassword = !String.IsNullOrEmpty(configuration.MailPassword) ? StringUtils.Encrypt(configuration.MailPassword) : oldconfig.MailPassword; configuration.CertificatePassword = !String.IsNullOrEmpty(configuration.CertificatePassword) ? StringUtils.Encrypt(configuration.CertificatePassword) : oldconfig.CertificatePassword; //--------------------- configuration.MerchantPublicKey = !String.IsNullOrEmpty(configuration.MerchantPublicKey) ? StringUtils.Encrypt(configuration.MerchantPublicKey) : oldconfig.MerchantPublicKey; configuration.MerchantPrivateKey = !String.IsNullOrEmpty(configuration.MerchantPrivateKey) ? StringUtils.Encrypt(configuration.MerchantPrivateKey) : oldconfig.MerchantPrivateKey; //------------------------ if ( !PaymentComponenets.Instance.DiscountTypeSectionTransactionalFacade(this.ContentManagerConnection) .Update(modelName, sectiontypes)) { throw new Exception(Resources.Congress.ErrorInEditConfuguration); } if (favIcon != null) { if (configuration.FavIcon == null) { configuration.FavIcon = fileTransactionalFacade.Insert(favIcon); } else { if (!fileTransactionalFacade.Update(favIcon, (Guid)configuration.FavIcon)) { throw new Exception("خطا در ذخیره fav icon وجود دارد"); } } } if (backgroundImageId != null) { if (configuration.BackgroundImage == null) { configuration.BackgroundImage = fileTransactionalFacade.Insert(backgroundImageId); } else { if (!fileTransactionalFacade.Update(backgroundImageId, (Guid)configuration.BackgroundImage)) { throw new Exception("خطایی در ذخیره عکس پشت زمینه وجود دارد"); } } configuration.BackgroundColor = null; } if (!string.IsNullOrEmpty(configuration.BackgroundColor)) { configuration.BackgroundImage = null; } if (!configurationBo.Update(this.ConnectionHandler, configuration)) { throw new Exception(Resources.Congress.ErrorInEditConfuguration); } if (configurationContent != null) { if (refreeAttachment != null) { if (configurationContent.AttachRefereeFileId == null) { configurationContent.AttachRefereeFileId = fileTransactionalFacade.Insert(refreeAttachment); } else { if ( !fileTransactionalFacade.Update(refreeAttachment, (Guid)configurationContent.AttachRefereeFileId)) { throw new Exception(string.Format(Resources.Congress.ErrorInEditArticleOrginalFile, configuration.ArticleTitle)); } } } if (boothMapAttachmentId != null) { if (configurationContent.BoothMapAttachmentId == null) { configurationContent.BoothMapAttachmentId = fileTransactionalFacade.Insert(boothMapAttachmentId); } else { if ( !fileTransactionalFacade.Update(boothMapAttachmentId, (Guid)configurationContent.BoothMapAttachmentId)) { throw new Exception(Resources.Congress.ErrorInEditBoothMapFile); } } } if (orginalPoster != null) { if (configurationContent.OrginalPosterId == null) { configurationContent.OrginalPosterId = fileTransactionalFacade.Insert(orginalPoster); } else { if ( !fileTransactionalFacade.Update(orginalPoster, (Guid)configurationContent.OrginalPosterId)) { throw new Exception(string.Format(Resources.Congress.ErrorInEditArticleOrginalFile, configuration.ArticleTitle)); } } } if (miniPoster != null) { if (configurationContent.MiniPosterId == null) { configurationContent.MiniPosterId = fileTransactionalFacade.Insert(miniPoster); } else { if (!fileTransactionalFacade.Update(miniPoster, (Guid)configurationContent.MiniPosterId)) { throw new Exception(Resources.Congress.ErrorInEditMiniPosterFile); } } } if (logo != null) { if (configurationContent.LogoId == null) { configurationContent.LogoId = fileTransactionalFacade.Insert(logo); } else { if (!fileTransactionalFacade.Update(logo, (Guid)configurationContent.LogoId)) { throw new Exception(Resources.Congress.ErrorInEditLogoFile); } } } if (header != null) { if (configurationContent.HeaderId == null) { configurationContent.HeaderId = fileTransactionalFacade.Insert(header); } else { if (!fileTransactionalFacade.Update(header, (Guid)configurationContent.HeaderId)) { throw new Exception(Resources.Congress.ErrorInEditHeaderFile); } } } if (footer != null) { if (configurationContent.FooterId == null) { configurationContent.FooterId = fileTransactionalFacade.Insert(footer); } else { if (!fileTransactionalFacade.Update(footer, (Guid)configurationContent.FooterId)) { throw new Exception(Resources.Congress.ErrorInEditFooterFile); } } } if (hallMapId != null) { if (configurationContent.HallMapId == null) { configurationContent.HallMapId = fileTransactionalFacade.Insert(hallMapId); } else { if (!fileTransactionalFacade.Update(footer, (Guid)configurationContent.HallMapId)) { throw new Exception(Resources.Congress.ErrorInEditHallmapFile); } } } if (configurationContent.ConfigurationId == Guid.Empty) { configurationContent.ConfigurationId = configuration.CongressId; if (!new ConfigurationContentBO().Insert(this.ConnectionHandler, configurationContent)) { throw new Exception(Resources.Congress.ErrorInSaveConfiguartion); } } else { var oldobj = new ConfigurationContentBO().Get(this.ConnectionHandler, configurationContent.ConfigurationId, configurationContent.LanguageId); if (oldobj != null) { if (oldobj.HeaderId.HasValue && configurationContent.HeaderId == null) { fileTransactionalFacade.Delete(oldobj.HeaderId); } if (oldobj.FooterId.HasValue && configurationContent.FooterId == null) { fileTransactionalFacade.Delete(oldobj.FooterId); } if (oldobj.LogoId.HasValue && configurationContent.LogoId == null) { fileTransactionalFacade.Delete(oldobj.LogoId); } if (oldobj.OrginalPosterId.HasValue && configurationContent.OrginalPosterId == null) { fileTransactionalFacade.Delete(oldobj.OrginalPosterId); } if (oldobj.MiniPosterId.HasValue && configurationContent.MiniPosterId == null) { fileTransactionalFacade.Delete(oldobj.MiniPosterId); } if (oldobj.AttachRefereeFileId.HasValue && configurationContent.AttachRefereeFileId == null) { fileTransactionalFacade.Delete(oldobj.AttachRefereeFileId); } if (oldobj.BoothMapAttachmentId.HasValue && configurationContent.BoothMapAttachmentId == null) { fileTransactionalFacade.Delete(oldobj.BoothMapAttachmentId); } } if (!new ConfigurationContentBO().Update(this.ConnectionHandler, configurationContent)) { throw new Exception(Resources.Congress.ErrorInEditConfuguration); } } } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); this.ContentManagerConnection.CommitTransaction(); this.PaymentConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); this.ContentManagerConnection.RollBack(); this.PaymentConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); this.ContentManagerConnection.RollBack(); this.PaymentConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool ConfigByDefaulToHoma(Guid homaId) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var defaulthoma = new HomaBO().FirstOrDefault(ConnectionHandler, x => x.IsDefaultForConfig); var configurationTranscationFacade = new ConfigurationBO(); var configurationContentTranscationFacade = new ConfigurationContentBO(); var fileTransactionalFacade = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection); if (defaulthoma != null) { var homa = new HomaBO().FirstOrDefault(ConnectionHandler, x => x.Id == homaId); if (defaulthoma.Id == homa.Id) { return(true); } if (homa.Configuration == null || homa.Configuration.CongressId == Guid.Empty) { var configuration1 = new ConfigurationBO().Get(ConnectionHandler, defaulthoma.Id); if (configuration1 != null) { configuration1.CongressId = homa.Id; var configurationContents = new ConfigurationContentBO().Where(ConnectionHandler, x => x.ConfigurationId == defaulthoma.Id); configurationTranscationFacade.Insert(ConnectionHandler, configuration1); foreach (var configurationContent in configurationContents) { configurationContent.ConfigurationId = homa.Id; if (configurationContent != null) { if (configurationContent.AttachRefereeFile != null) { var AttachRefereeFile = Guid.NewGuid(); configurationContent.AttachRefereeFile.Id = AttachRefereeFile; configurationContent.AttachRefereeFileId = AttachRefereeFile; fileTransactionalFacade.Insert(configurationContent.AttachRefereeFile); } if (configurationContent.BoothMapAttachment != null) { var BoothMapAttachment = Guid.NewGuid(); configurationContent.BoothMapAttachment.Id = BoothMapAttachment; configurationContent.BoothMapAttachmentId = BoothMapAttachment; fileTransactionalFacade.Insert(configurationContent.BoothMapAttachment); } if (configurationContent.OrginalPoster != null) { var OrginalPoster = Guid.NewGuid(); configurationContent.OrginalPoster.Id = OrginalPoster; configurationContent.OrginalPosterId = OrginalPoster; fileTransactionalFacade.Insert(configurationContent.OrginalPoster); } if (configurationContent.MiniPoster != null) { var MiniPoster = Guid.NewGuid(); configurationContent.MiniPoster.Id = MiniPoster; configurationContent.MiniPosterId = MiniPoster; fileTransactionalFacade.Insert(configurationContent.MiniPoster); } if (configurationContent.Logo != null) { var logoId = Guid.NewGuid(); configurationContent.Logo.Id = logoId; configurationContent.LogoId = logoId; fileTransactionalFacade.Insert(configurationContent.Logo); } if (configurationContent.Header != null) { var headerId = Guid.NewGuid(); configurationContent.HeaderId = headerId; configurationContent.Header.Id = headerId; fileTransactionalFacade.Insert(configurationContent.Header); } if (configurationContent.Footer != null) { var logoId = Guid.NewGuid(); configurationContent.FooterId = logoId; configurationContent.Footer.Id = logoId; fileTransactionalFacade.Insert(configurationContent.Footer); } if (configurationContent.HallMap != null) { var HallMap = Guid.NewGuid(); configurationContent.HallMapId = HallMap; configurationContent.HallMap.Id = HallMap; fileTransactionalFacade.Insert(configurationContent.HallMap); } } configurationContentTranscationFacade.Insert(ConnectionHandler, configurationContent); } } } var congressLanguageBo = new CongressLanguageBO(); var congressLanguages = congressLanguageBo.Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressLanguages != null) { var congressMenuTranscationFacade = congressLanguageBo; foreach (var congressLanguage in congressLanguages) { congressLanguage.CongressId = homa.Id; congressMenuTranscationFacade.Insert(ConnectionHandler, congressLanguage); } } var congressContentBo = new CongressContentBO(); var congressContents = congressContentBo.Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressContents != null) { var contentContentFacade = ContentManagerComponent.Instance.ContentTransactionalFacade(ConnectionHandler); var contentFacade = ContentManagerComponent.Instance.ContentContentTransactionalFacade(ConnectionHandler); foreach (var congressContent in congressContents) { var oldid = congressContent.ContentId; var contents = contentFacade.Where(x => x.Id == oldid); contentContentFacade.Insert(congressContent.Content); foreach (var contentContent in contents) { contentContent.Id = congressContent.Content.Id; contentFacade.Insert(contentContent); } congressContent.CongressId = homa.Id; congressContent.ContentId = congressContent.Content.Id; congressContentBo.Insert(ConnectionHandler, congressContent); } } var congressContainers = new CongressContainerBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressContainers != null) { var congressMenuTranscationFacade = new CongressContainerFacade(ConnectionHandler); foreach (var congressMenu in congressContainers) { var newGuid = Guid.NewGuid(); congressMenu.Container.Id = newGuid; congressMenu.ContainerId = newGuid; congressMenu.CongressId = homa.Id; congressMenuTranscationFacade.Insert(homa.Id, congressMenu.Container); } } var congressMenus = new CongressMenuHtmlBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressMenus != null) { var congressMenuTranscationFacade = new CongressMenuHtmlFacade(ConnectionHandler); foreach (var congressMenu in congressMenus) { var newGuid = Guid.NewGuid(); congressMenu.MenuHtml.Id = newGuid; congressMenu.MenuHtmlId = newGuid; congressMenu.CongressId = homa.Id; congressMenuTranscationFacade.Insert(homa.Id, congressMenu.MenuHtml); } } var @where = new CongressHtmlBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (@where != null) { var congressMenuTranscationFacade = new CongressHtmlFacade(ConnectionHandler); foreach (var congressMenu in @where) { var oldId = congressMenu.HtmlDesginId; var newGuid = Guid.NewGuid(); congressMenu.HtmlDesgin.Id = newGuid; congressMenu.HtmlDesginId = newGuid; congressMenu.CongressId = homa.Id; congressMenuTranscationFacade.Insert(homa.Id, congressMenu.HtmlDesgin); var partialLoadTransactionalFacade = ContentManagerComponent.Instance.PartialLoadTransactionalFacade(ConnectionHandler); var list = partialLoadTransactionalFacade.Where(x => x.HtmlDesginId == oldId); foreach (var partialLoad in list) { partialLoad.HtmlDesginId = newGuid; partialLoadTransactionalFacade.Insert(partialLoad); } } } var congressId = new CongressMenuBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressId != null) { var congressMenuTranscationFacade = new CongressMenuFacade(ConnectionHandler); foreach (var congressMenu in congressId) { var newGuid = Guid.NewGuid(); congressMenu.Menu.Id = newGuid; congressMenu.MenuId = newGuid; congressMenu.CongressId = homa.Id; congressMenuTranscationFacade.Insert(homa.Id, congressMenu.Menu, null); } } var formAssigmentTransactionalFacade = FormGeneratorComponent.Instance.FormAssigmentTransactionalFacade(ConnectionHandler); var congressFormses = new CongressFormsBO().Where(ConnectionHandler, x => x.CongressId == defaulthoma.Id); if (congressFormses != null) { var congressFormsFacade = new CongressFormsFacade(ConnectionHandler); foreach (var congressForms in congressFormses) { var oldId = congressForms.FomId; var formAssigments = formAssigmentTransactionalFacade.Where(x => x.FormStructureId == oldId); var newGuid = Guid.NewGuid(); var newGuidStructureFileId = Guid.NewGuid(); congressForms.FormStructure.Id = newGuid; congressForms.FomId = newGuid; congressForms.CongressId = homa.Id; if (!string.IsNullOrEmpty(congressForms.FormStructure.StructureFileId)) { var file = fileTransactionalFacade.Get(congressForms.FormStructure.StructureFileId); if (file != null) { file.Id = newGuidStructureFileId; fileTransactionalFacade.Insert(file); congressForms.FormStructure.StructureFileId = newGuidStructureFileId.ToString(); } } congressFormsFacade.Insert(homa.Id, congressForms.FormStructure); foreach (var formAssigment in formAssigments) { formAssigment.FormStructureId = newGuid; formAssigmentTransactionalFacade.Insert(formAssigment); } } } } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); throw new KnownException(ex.Message, ex); } return(true); }
protected override void IntializeBO() { this.BO = (ConfigurationBO)SingletonManager.GetSingleton(typeof(ConfigurationBO)); this.BO.LoadConfiguration(1); }
public bool Update(Guid congressId, Slide slide, string usefor) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.SliderConnection.StartTransaction(IsolationLevel.ReadUncommitted); if (!SliderComponent.Instance.SlideTransactionalFacade(this.SliderConnection).Update(slide)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } var configurationBo = new ConfigurationBO(); var config = configurationBo.ValidConfig(this.ConnectionHandler, congressId); if (!string.IsNullOrEmpty(usefor)) { switch (usefor) { case "1": config.BigSlideId = slide.Id; if (config.AverageSlideId == slide.Id) { config.AverageSlideId = null; } if (config.MiniSlideId == slide.Id) { config.MiniSlideId = null; } break; case "0": config.AverageSlideId = slide.Id; if (config.BigSlideId == slide.Id) { config.BigSlideId = null; } if (config.MiniSlideId == slide.Id) { config.MiniSlideId = null; } break; case "-1": config.MiniSlideId = slide.Id; if (config.AverageSlideId == slide.Id) { config.AverageSlideId = null; } if (config.BigSlideId == slide.Id) { config.BigSlideId = null; } break; } } else { if (config.BigSlideId == slide.Id) { config.BigSlideId = null; } if (config.AverageSlideId == slide.Id) { config.AverageSlideId = null; } if (config.MiniSlideId == slide.Id) { config.MiniSlideId = null; } } if (!configurationBo.Update(this.ConnectionHandler, config)) { throw new Exception(Resources.Congress.ErrorInEditConfuguration); } this.ConnectionHandler.CommitTransaction(); this.SliderConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool Insert(Guid websiteId, Slide slide, string url) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.SliderConnection.StartTransaction(IsolationLevel.ReadUncommitted); slide.IsExternal = true; if (!SliderComponent.Instance.SlideTransactionalFacade(this.SliderConnection).Insert(slide)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } var congessSlide = new DataStructure.Slider() { SlideId = slide.Id, WebId = websiteId }; if (!new SliderBO().Insert(this.ConnectionHandler, congessSlide)) { throw new Exception("خطایی درذخیره گالری وجود دارد"); } if (!string.IsNullOrEmpty(url)) { var configurationBo = new ConfigurationBO(); var config = configurationBo.Get(this.ConnectionHandler, websiteId); if (config == null) { return(false); } switch (url) { case "1": config.BigSlideId = slide.Id; break; case "0": config.AverageSlideId = slide.Id; break; case "-1": config.MiniSlideId = slide.Id; break; } if (!configurationBo.Update(this.ConnectionHandler, config)) { throw new Exception("خطایی درذخیره تنظیمات وجود دارد"); } } this.ConnectionHandler.CommitTransaction(); this.SliderConnection.CommitTransaction(); return(true); } catch (KnownException knownException) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.SliderConnection.RollBack(); throw new KnownException(ex.Message, ex); } }