Exemplo n.º 1
0
        private async Task<InventionJob> GetInventionJob(Domains.IndustryJob job, BlueprintInfo t2Print, IEnumerable<Decryptor> decryptors, IEnumerable<MarketPrice> invMatPrices)
        {
            try
            {
                var types = new List<int> { t2Print.Manufacturing.Products.First().TypeId };
                var rawMaterials = await _manufacturingService.GetRawMaterials(new Domains.IndustryJob(t2Print, new Blueprint(1, 0, 0, 1)), 1);
                types.AddRange(rawMaterials.Select(p => p.TypeId).ToList());

                var marketStats = await _apiService.GetMarketStatistics(types, 30000142);

                var baseRuns = t2Print.Manufacturing.Products.First().CategoryId == 6 ? 1 : 10;
                var costOfInvention = job.BlueprintInfo.Invention.Materials.Sum(material => invMatPrices.First().Buy * Convert.ToDecimal(material.Quantity));

                var t2Item = await _staticService.GetProductTypeAsync(t2Print.BlueprintId);
                var t1Item = await _staticService.GetProductTypeAsync(job.BlueprintInfo.BlueprintId);

                var tasks = decryptors.Select(p => CheckDecryptor(p, job, t2Print, costOfInvention, baseRuns, marketStats)).ToList();
                var inventionJob = new InventionJob(t2Item.TypeId, t2Item.TypeName, t1Item.TypeId, t1Item.TypeName, 0, new List<Decryptor>());

                while (tasks.Any())
                {
                    var task = await Task.WhenAny(tasks);
                    inventionJob.Decryptors.Add(await task);
                    tasks.Remove(task);
                }

                return inventionJob;
            }
            catch (Exception e)
            {
                throw new Exception($"Invention of {t2Print.Manufacturing.Products.First().TypeName} failed with message: {e.Message}");
            }
        }
Exemplo n.º 2
0
 public object Get(Domains request)
 {
     if (string.IsNullOrEmpty(request.domainName))
         return Engine.GetDomains();
     return Engine.GetDomains().FirstOrDefault(
         d => string.Equals(d.DomainName.Trim(), request.domainName.Trim(),
             StringComparison.CurrentCultureIgnoreCase));
 }
Exemplo n.º 3
0
        protected internal virtual Domains GetCurrentDomains()
        {
            var max = this.DomainMaxFetchCount;
            var currentDomains = new Domains();
            string nextToken = null;
            do
            {
                var fetched = this.SimpleDbClient.ListDomains(maxNumberToRetrive: max);
                nextToken = fetched.NextToken;
                currentDomains.AddRange(fetched);

            } while (nextToken != null);

            return currentDomains;
        }
Exemplo n.º 4
0
 internal Domain <T> GetDomain(string key) => Domains.First(d => d.Key == key);
Exemplo n.º 5
0
        public void Reload(Domains domain)
        {
            FileInfo  file;
            string    name = Enum.GetName(typeof(Domains), domain);
            AppDomain ad   = AppDomain.CreateDomain(name);

            byte[] assembly;
            file = new FileInfo("Aselia." + name + ".dll");
            using (FileStream fs = file.OpenRead())
            {
                assembly = new byte[fs.Length];
                fs.Read(assembly, 0, assembly.Length);
            }

            Assembly asm = null;

            ad.Load(assembly);
            foreach (Assembly a in ad.GetAssemblies())
            {
                if (a.FullName.Contains("Aselia"))
                {
                    asm = a;
                    break;
                }
            }
            if (asm == null)
            {
                throw new Exception("Could not find valid Aselia assembly in DLL.");
            }

            try
            {
                Initialize(domain, asm);
                Console.WriteLine("Loaded {0}.", asm.FullName);
            }
            catch (Exception ex)
            {
                try
                {
                    AppDomain.Unload(ad);
                }
                catch
                {
                }
                throw new Exception("Error initializing new domain.", ex);
            }

#if UNLOAD
            AppDomain remove = AppDomains.ContainsKey(domain) ? AppDomains[domain] : null;
#endif

            AppDomains[domain] = ad;

#if UNLOAD
            if (remove != null)
            {
                try
                {
                    AppDomain.Unload(remove);
                }
                catch (Exception ex)
                {
                    throw new Exception("Loaded new domain, but error unloading old domain.", ex);
                }
            }
#endif
        }
Exemplo n.º 6
0
 public bool?Execute(Domains domains, IAddonInteractive interactive)
 {
     return(false);
 }
Exemplo n.º 7
0
 public virtual string GetCookies()
 {
     return(cookieContainer.GetCookieHeader(new Uri(Domains.GetEnumerator().Current)));
 }
Exemplo n.º 8
0
 internal override void OnCommit()
 {
     Domains.TryRemove(_identity, out Aggregate);
 }
Exemplo n.º 9
0
        public Domain AddDomain(Domains oDomains, string sName)
        {
            Domain oDomain = oDomains.Add();
             oDomain.Name = sName;
             oDomain.Active = true;
             oDomain.Save();

             return oDomain;
        }
Exemplo n.º 10
0
        private void Initialize(Domains domain, Assembly asm)
        {
            switch (domain)
            {
            case Domains.Core:
                InitializeCore(asm);
                break;

            case Domains.UserCommands:
                InitializeUserCommand(asm);
                break;

            case Domains.ChannelModes:
                InitializeChannelMode(asm);
                break;

            case Domains.UserModes:
                InitializeUserMode(asm);
                break;
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Register([FromBody] RegisterRequestViewModel model)
        {
            //var aVal = 0; var blowUp = 1 / aVal;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Domains.IsValid(model.Domain))
            {
                return(BadRequest("Domain not supported"));
            }

            var user = new AppUser
            {
                DomainUsername = model.DomainUsername,
                UserName       = model.Email,
                Name           = model.Name,
                Email          = model.Email,
                Domain         = model.Domain
            };


            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors));
            }

            var appUser = new User()
            {
                Email  = model.Email,
                AdUser = new ADUser()
                {
                    Username = model.DomainUsername,
                    Groups   = new List <string>(model.Groups)
                },
                Interests  = new List <string>(model.Interests),
                Name       = model.Name,
                Surname    = model.Surname,
                IdentityId = (await _userManager.FindByEmailAsync(model.Email)).Id
            };

            var appRegister = new CreateUserRequest()
            {
                Key  = _config["KEY"],
                User = appUser
            };

            Api.MakeRequest(_config["API_ADDRESS"] + "/Identity/createUser", JsonConvert.SerializeObject(appRegister));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("username", user.UserName));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("name", user.Name));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("email", user.Email));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("role", Roles.Student));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("domain", user.Domain));

            await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("domainUsername", user.DomainUsername));

            foreach (var interest in model.Interests)
            {
                await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("interest", interest));
            }

            foreach (var group in model.Groups)
            {
                await _userManager.AddClaimAsync(user, new System.Security.Claims.Claim("group", group));
            }

            return(Ok(new RegisterResponseViewModel(user)));
        }
Exemplo n.º 12
0
 public List <Schema> GetAllSchemas()
 {
     return(Domains
            .SelectMany(k => k.Schemas)
            .ToList());
 }
Exemplo n.º 13
0
 public static ProfileData createProfile(Domains site) {
   ProfileData res = createProfileStart(site);
   WriteProfile(res);
   return res;
 }
Exemplo n.º 14
0
 public static IEnumerable <Domain> List(this Domains domains, Filter filter)
 {
     return(domains.List().Where(domain => filter(domain)));
 }
Exemplo n.º 15
0
 public static ProfileData createProfileStart(Domains site) {
   ProfileData res = new ProfileData();
   res.Created = DateTime.UtcNow;
   res.Site = site;
   //res.Version = 1;
   if (Machines.isBuildEACache_BuildCD_Crawler) {
     res.Id = 12345;
   } else {
     res.Id = getUniqueId(LMComDataProvider.uiUserId);
     res.Referer = HttpContext.Current.Request.UrlReferrer == null ? null : HttpContext.Current.Request.UrlReferrer.AbsolutePath;
   }
   return res;
 }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
            RequestFields   oRequestField   = new RequestFields(intProfile, dsn);
            ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
            Services        oService        = new Services(intProfile, dsn);
            int             intRequest      = Int32.Parse(Request.QueryString["rid"]);
            string          strStatus       = oServiceRequest.Get(intRequest, "checkout");
            DataSet         dsItems         = oRequestItem.GetForms(intRequest);
            int             intItem         = 0;
            int             intService      = 0;
            int             intNumber       = 0;

            if (dsItems.Tables[0].Rows.Count > 0)
            {
                bool boolBreak = false;
                foreach (DataRow drItem in dsItems.Tables[0].Rows)
                {
                    if (boolBreak == true)
                    {
                        break;
                    }
                    if (drItem["done"].ToString() == "0")
                    {
                        intItem    = Int32.Parse(drItem["itemid"].ToString());
                        intService = Int32.Parse(drItem["serviceid"].ToString());
                        intNumber  = Int32.Parse(drItem["number"].ToString());
                        boolBreak  = true;
                    }
                    if (intItem > 0 && (strStatus == "1" || strStatus == "2"))
                    {
                        bool          boolSuccess = true;
                        StringBuilder sbResult    = new StringBuilder(oService.GetName(intService) + " Completed");
                        StringBuilder sbError     = new StringBuilder(oService.GetName(intService) + " Error");

                        // ********* BEGIN PROCESSING **************
                        AccountRequest oAccountRequest = new AccountRequest(intProfile, dsn);
                        Requests       oRequest        = new Requests(intProfile, dsn);
                        Users          oUser           = new Users(intProfile, dsn);
                        DataSet        ds      = oAccountRequest.GetMaintenance(intRequest, intItem, intNumber);
                        Domains        oDomain = new Domains(intProfile, dsn);
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            string         strUser      = ds.Tables[0].Rows[0]["username"].ToString();
                            int            intDomain    = Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString());
                            int            intEnv       = Int32.Parse(oDomain.Get(intDomain, "environment"));
                            int            intUser      = oRequest.GetUser(intRequest);
                            DataSet        dsParameters = oAccountRequest.GetMaintenanceParameters(intRequest, intItem, intNumber);
                            AD             oAD          = new AD(intProfile, dsn, intEnv);
                            DirectoryEntry oEntry       = oAD.UserSearch(strUser);

                            if (oEntry == null)
                            {
                                sbResult = new StringBuilder();
                            }
                            else
                            {
                                sbError = new StringBuilder();

                                string strFirstOld = "";
                                if (oEntry.Properties.Contains("givenname") == true)
                                {
                                    strFirstOld = oEntry.Properties["givenname"].Value.ToString();
                                }
                                string strLastOld = "";
                                if (oEntry.Properties.Contains("sn") == true)
                                {
                                    strLastOld = oEntry.Properties["sn"].Value.ToString();
                                }
                                string strFirstNew        = dsParameters.Tables[0].Rows[0]["value"].ToString();
                                string strLastNew         = dsParameters.Tables[0].Rows[1]["value"].ToString();
                                string strEnable          = dsParameters.Tables[0].Rows[2]["value"].ToString();
                                string strUnlock          = dsParameters.Tables[0].Rows[3]["value"].ToString();
                                string strGroupsRequested = dsParameters.Tables[0].Rows[4]["value"].ToString();
                                if (strFirstOld != strFirstNew || strLastOld != strLastNew)
                                {
                                    if (strFirstOld != strFirstNew && strLastOld != strLastNew)
                                    {
                                        oEntry.Properties["givenname"].Value   = strFirstNew;
                                        oEntry.Properties["sn"].Value          = strLastNew;
                                        oEntry.Properties["displayname"].Value = strLastNew + ", " + strFirstNew;
                                        oEntry.CommitChanges();
                                        sbResult.Append("<p>The first name and last name for account ");
                                        sbResult.Append(strUser);
                                        sbResult.Append(" was successfully updated</p>");
                                    }
                                    else if (strFirstOld != strFirstNew)
                                    {
                                        oEntry.Properties["givenname"].Value   = strFirstNew;
                                        oEntry.Properties["displayname"].Value = strLastNew + ", " + strFirstNew;
                                        oEntry.CommitChanges();
                                        sbResult.Append("<p>The first name for account ");
                                        sbResult.Append(strUser);
                                        sbResult.Append(" was successfully updated</p>");
                                    }
                                    else
                                    {
                                        oEntry.Properties["sn"].Value          = strLastNew;
                                        oEntry.Properties["displayname"].Value = strLastNew + ", " + strFirstNew;
                                        oEntry.CommitChanges();
                                        sbResult.Append("<p>The last name for account ");
                                        sbResult.Append(strUser);
                                        sbResult.Append(" was successfully updated</p>");
                                    }
                                }
                                if (strEnable == "1")
                                {
                                    strEnable = oAD.Enable(oEntry, true);
                                    if (strEnable == "")
                                    {
                                        sbResult.Append("<p>The user account ");
                                        sbResult.Append(strUser);
                                        sbResult.Append(" was successfully enabled</p>");
                                    }
                                    else
                                    {
                                        sbError.Append("<p>The user account ");
                                        sbError.Append(strUser);
                                        sbError.Append(" was NOT successfully enabled</p>");
                                    }
                                }
                                if (strUnlock == "1")
                                {
                                    strUnlock = oAD.Unlock(oEntry);
                                    if (strUnlock == "")
                                    {
                                        sbResult.Append("<p>The user account ");
                                        sbResult.Append(strUser);
                                        sbResult.Append(" was successfully unlocked</p>");
                                    }
                                    else
                                    {
                                        sbError.Append("<p>The user account ");
                                        sbError.Append(strUser);
                                        sbError.Append(" was NOT successfully unlocked</p>");
                                    }
                                }

                                string   strGroupsExist = oAD.GetGroups(oEntry);
                                string[] strGroupRequested;
                                string[] strGroupExist;
                                char[]   strSplit = { ';' };
                                strGroupRequested = strGroupsRequested.Split(strSplit);
                                strGroupExist     = strGroupsExist.Split(strSplit);

                                // Add Groups
                                for (int ii = 0; ii < strGroupRequested.Length; ii++)
                                {
                                    if (strGroupRequested[ii].Trim() != "")
                                    {
                                        bool boolExist = false;
                                        for (int jj = 0; jj < strGroupExist.Length; jj++)
                                        {
                                            if (strGroupExist[jj].Trim() != "" && strGroupRequested[ii].Trim() == strGroupExist[jj].Trim())
                                            {
                                                boolExist = true;
                                                break;
                                            }
                                        }
                                        if (boolExist == false)
                                        {
                                            // Add the group
                                            string strJoin = oAD.JoinGroup(strUser, strGroupRequested[ii].Trim(), 0);
                                            if (strJoin == "")
                                            {
                                                sbResult.Append("<p>The user ");
                                                sbResult.Append(strUser);
                                                sbResult.Append(" was successfully joined to the group ");
                                                sbResult.Append(strGroupRequested[ii].Trim());
                                                sbResult.Append("</p>");
                                            }
                                            else
                                            {
                                                sbError.Append("<p>The user ");
                                                sbError.Append(strUser);
                                                sbError.Append(" was NOT successfully joined to the group ");
                                                sbError.Append(strGroupRequested[ii].Trim());
                                                sbError.Append(" : ");
                                                sbError.Append(strJoin);
                                                sbError.Append("</p>");
                                            }
                                        }
                                    }
                                }
                                // Remove Groups
                                for (int ii = 0; ii < strGroupExist.Length; ii++)
                                {
                                    if (strGroupExist[ii].Trim() != "")
                                    {
                                        bool boolExist = false;
                                        for (int jj = 0; jj < strGroupRequested.Length; jj++)
                                        {
                                            if (strGroupRequested[jj].Trim() != "" && strGroupExist[ii].Trim() == strGroupRequested[jj].Trim())
                                            {
                                                boolExist = true;
                                                break;
                                            }
                                        }
                                        if (boolExist == false)
                                        {
                                            // Remove the group
                                            string strJoin = oAD.RemoveGroup(strUser, strGroupExist[ii].Trim());
                                            if (strJoin == "")
                                            {
                                                sbResult.Append("<p>The user ");
                                                sbResult.Append(strUser);
                                                sbResult.Append(" was successfully removed from the group ");
                                                sbResult.Append(strGroupExist[ii].Trim());
                                                sbResult.Append("</p>");
                                            }
                                            else
                                            {
                                                sbError.Append("<p>The user ");
                                                sbError.Append(strUser);
                                                sbError.Append(" was NOT successfully removed from the group ");
                                                sbError.Append(strGroupExist[ii].Trim());
                                                sbError.Append(" : ");
                                                sbError.Append(strJoin);
                                                sbError.Append("</p>");
                                            }
                                        }
                                    }
                                }
                                oRequest.AddResult(intRequest, intItem, intNumber, "Account Modification", sbError.ToString(), sbResult.ToString(), intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                            }
                        }

                        if (sbResult.ToString() == "")
                        {
                            boolSuccess = false;
                        }

                        // ******** END PROCESSING **************
                        if (oService.Get(intService, "automate") == "1" && boolSuccess == true)
                        {
                            strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + sbResult.ToString() + "</td></tr></table>";
                        }
                        else
                        {
                            if (boolSuccess == false)
                            {
                                strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_error.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + sbError.ToString() + "</td></tr></table>";
                            }
                            else
                            {
                                strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>";
                            }
                        }
                        oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1);
                    }
                }
            }
        }
Exemplo n.º 17
0
        public void Reload(Domains domain)
        {
            FileInfo file;
            string name = Enum.GetName(typeof(Domains), domain);
            AppDomain ad = AppDomain.CreateDomain(name);

            byte[] assembly;
            file = new FileInfo("Aselia." + name + ".dll");
            using (FileStream fs = file.OpenRead())
            {
                assembly = new byte[fs.Length];
                fs.Read(assembly, 0, assembly.Length);
            }

            Assembly asm = null;
            ad.Load(assembly);
            foreach (Assembly a in ad.GetAssemblies())
            {
                if (a.FullName.Contains("Aselia"))
                {
                    asm = a;
                    break;
                }
            }
            if (asm == null)
            {
                throw new Exception("Could not find valid Aselia assembly in DLL.");
            }

            try
            {
                Initialize(domain, asm);
                Console.WriteLine("Loaded {0}.", asm.FullName);
            }
            catch (Exception ex)
            {
                try
                {
                    AppDomain.Unload(ad);
                }
                catch
                {
                }
                throw new Exception("Error initializing new domain.", ex);
            }

            #if UNLOAD
            AppDomain remove = AppDomains.ContainsKey(domain) ? AppDomains[domain] : null;
            #endif

            AppDomains[domain] = ad;

            #if UNLOAD
            if (remove != null)
            {
                try
                {
                    AppDomain.Unload(remove);
                }
                catch (Exception ex)
                {
                    throw new Exception("Loaded new domain, but error unloading old domain.", ex);
                }
            }
            #endif
        }
 /// <summary>Returns an enumerator that iterates through the resources in this response.</summary>
 public scg::IEnumerator <AuthorizedDomain> GetEnumerator() => Domains.GetEnumerator();
Exemplo n.º 19
0
 public void AddDomain(Domain domain)
 {
     Domains.Add(domain.Id, domain);
 }
Exemplo n.º 20
0
 public void AddDomain(ConnectDomain domain)
 {
     Domains.Add(domain);
 }
        private void GetAllDomains(
            IList <IDomain> domains,
            ParameterInfo parameter,
            object factory)
        {
            foreach (MethodInfo factoryMethod in ReflectionHelper.GetMethods(factory.GetType(), typeof(FactoryAttribute)))
            {
                if (factoryMethod.GetParameters().Length > 0)
                {
                    continue;
                }
                Type returnType = factoryMethod.ReturnType;

                // check single object return
                if (parameter.ParameterType.IsAssignableFrom(returnType))
                {
                    object  result = factoryMethod.Invoke(factory, null);
                    IDomain domain = Domains.ToDomain(result);
                    domain.Name = factoryMethod.Name;
                    domains.Add(domain);
                    continue;
                }

                // check array
                if (returnType.HasElementType)
                {
                    Type elementType = returnType.GetElementType();
                    if (parameter.ParameterType == elementType)
                    {
                        object  result = factoryMethod.Invoke(factory, null);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }

                // check IEnumerable
                if (returnType.IsGenericType)
                {
                    if (typeof(IEnumerable <>).IsAssignableFrom(returnType.GetGenericTypeDefinition()))
                    {
                        if (parameter.ParameterType.IsAssignableFrom(returnType.GetGenericArguments()[0]))
                        {
                            object  result = factoryMethod.Invoke(factory, null);
                            IDomain domain = Domains.ToDomain(result);
                            domain.Name = factoryMethod.Name;
                            domains.Add(domain);
                            continue;
                        }
                    }
                }

                // check factory type
                FactoryAttribute factoryAttribute = ReflectionHelper.GetAttribute <FactoryAttribute>(factoryMethod);
                if (factoryAttribute != null)
                {
                    Type factoredType = factoryAttribute.FactoredType;
                    if (parameter.ParameterType == factoredType)
                    {
                        object  result = factoryMethod.Invoke(factory, null);
                        IDomain domain = Domains.ToDomain(result);
                        domain.Name = factoryMethod.Name;
                        domains.Add(domain);
                        continue;
                    }
                }
            }
        }
Exemplo n.º 22
0
 public string Url(Domains homeSite, int dbId) {
   if (Type == SiteMapNodeType.folder) return "folder/" + dbId.ToString();
   return string.Format(@"~/{0}/web/lang/{1}/{2}.{3}",
     homeSite != Domains.site && SiteId == Domains.site ? "site-" + homeSite.ToString() : SiteId.ToString(),
     Security, Name, Ext);
 }
Exemplo n.º 23
0
        private async Task<Decryptor> CheckDecryptor(Decryptor decryptor, Domains.IndustryJob job, BlueprintInfo t2Print, decimal costOfInvention, int baseRuns, IEnumerable<MarketPrice> materialPrices)
        {
            try
            {
                var probability = await job.GetInventionSuccessProbability(5, 5, 5, decryptor.ProbabilityModifier);

                if (decryptor.TypeId > 0)
                    costOfInvention += decryptor.Price;

                var runs = baseRuns + decryptor.MaxRunModifier;

                var t2Job = new Domains.IndustryJob(t2Print, new Blueprint { MaterialEfficiency = 2 + decryptor.MaterialEfficiencyModifier });

                var materials = await _manufacturingService.GetRawMaterials(t2Job, 1);

                var itemCost = materials.Sum(mat => materialPrices.First(p => p.TypeId == mat.TypeId).Buy * mat.Quantity);

                var inventionCostPerRun = costOfInvention / runs * probability * (decimal)t2Print.Manufacturing.Products.First().Quantity;

                var dec = new Decryptor(decryptor.TypeId, decryptor.TypeName, decryptor.ProbabilityModifier,
                    decryptor.MaxRunModifier, decryptor.MaterialEfficiencyModifier, decryptor.TimeEfficiencyModifier,
                    decryptor.Price);

                dec.ProfitPerInvention = materialPrices.First(p => p.TypeId == t2Print.Manufacturing.Products.First().TypeId).Buy - inventionCostPerRun - itemCost;
                dec.ME = 2 + decryptor.MaterialEfficiencyModifier;
                dec.TE = 4 + decryptor.TimeEfficiencyModifier;
                dec.Runs = runs;

                return dec;
            }
            catch (Exception e)
            {
                throw new Exception($"{t2Print.Manufacturing.Products.First().TypeName} Failed with {decryptor.TypeName} with message: {e.Message}");
            }
            
        }
Exemplo n.º 24
0
 public Domain GetDomain(string name)
 {
     return(Domains.FirstOrDefault(k => k.Name == name));
 }
Exemplo n.º 25
0
 public static string siteApp(Domains site, LMApps app) {
   return site.ToString() + app.ToString();
 }
        public async void OnNavigatedTo(NavigationContext navigationContext)
        {
            var items = await _domains.GetItems();

            items.ForEach(e => Domains.Add(new BindableEntity(e)));
        }
Exemplo n.º 27
0
    //public static string GetUrl(SiteMapNode nd) {
    //  string url = VirtualPathUtility.ToAppRelative(nd.Url.ToLowerInvariant());
    //  string[] parts = url.Split(new char[] { '/' }, 5);
    //  if (parts.Length != 5) throw new Exception();
    //  return GetUrl((LMApps)Enum.Parse(typeof(LMApps), parts[2], true), parts[4]);
    //}

    public static string getTitle(Domains site, string lng, string path) {
      SiteMapNode nd = SiteMap.Provider.FindSiteMapNode("~/site-" + site.ToString() + "/web/lang/" + path);
      if (nd == null) return "urlInfo.getTitle";
      CultureInfo oldCi = Thread.CurrentThread.CurrentUICulture;
      try {
        urlInfo.setCulture(lng);
        return nd.Title;
      } finally { Thread.CurrentThread.CurrentUICulture = oldCi; }
    }
Exemplo n.º 28
0
        static UrlManager()
        {
            // Create the dictionaries
            HostNameDictionary =
                new Dictionary <string, HostNameInfo>(StringComparer.OrdinalIgnoreCase);
            StateCodeDictionary =
                new Dictionary <string, HostNameInfo>(StringComparer.OrdinalIgnoreCase);
            DesignCodeDictionary =
                new Dictionary <string, HostNameInfo>(StringComparer.OrdinalIgnoreCase);
            CurrentDomainDataCodeCache =
                new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            CurrentDomainOrganizationCodeCache =
                new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            // Get the live host name / test host name mode
            if (
                !bool.TryParse(
                    ConfigurationManager.AppSettings[UseLiveHostNamesKey], out UseLiveHostNames))
            {
                UseLiveHostNames = false;
            }

            if (HttpContext.Current != null)
            {
                var port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
                if (!int.TryParse(port, out CurrentPort))
                {
                    CurrentPort = 80;
                }
            }

            var table = Domains.GetAllUrlManagerData();

            foreach (var row in table)
            {
                // We only process entries with the blessed DomainOrganizationCode
                // and that have a non-empty TestServer name
                if (row.DomainOrganizationCode == BlessedDomainOrganizationCode &&
                    !string.IsNullOrWhiteSpace(row.TestServerName))
                {
                    // Create a HostNameInfo object
                    var hostNameInfo = new HostNameInfo
                    {
                        Name        = UseLiveHostNames ? row.DomainServerName : row.TestServerName,
                        LiveName    = row.DomainServerName,
                        IsCanonical = row.IsCanonical,
                        StateCode   = row.StateCode,
                        DesignCode  = row.DomainDesignCode
                    };

                    // Add to the DomainNameDictionary
                    if (HostNameDictionary.ContainsKey(hostNameInfo.Name))
                    {
                        throw new VoteException(
                                  "UrlManager: duplicate host name \"{0\"", hostNameInfo.Name);
                    }
                    HostNameDictionary.Add(hostNameInfo.Name, hostNameInfo);

                    // If canonical, add to the StateCodeDictionary and DesignCodeDictionary
                    if (hostNameInfo.IsCanonical)
                    {
                        if (StateCodeDictionary.ContainsKey(hostNameInfo.StateCode))
                        {
                            throw new VoteException(
                                      "UrlManager: duplicate canonical host name \"{0\" for state \"{1}\"",
                                      hostNameInfo.Name, hostNameInfo.StateCode);
                        }
                        StateCodeDictionary.Add(hostNameInfo.StateCode, hostNameInfo);

                        if (DesignCodeDictionary.ContainsKey(hostNameInfo.DesignCode))
                        {
                            throw new VoteException(
                                      "UrlManager: duplicate canonical host name \"{0\" for design code \"{1}\"",
                                      hostNameInfo.Name, hostNameInfo.DesignCode);
                        }
                        DesignCodeDictionary.Add(hostNameInfo.DesignCode, hostNameInfo);
                    }
                }
            }

            if (!StateCodeDictionary.ContainsKey(AllStatesStateCode))
            {
                throw new VoteException(
                          "UrlManager: there is no canonical host name for the all-states state code (\"{0}\")",
                          AllStatesStateCode);
            }
            CanonicalSiteNameInfo = StateCodeDictionary[AllStatesStateCode];
        }
Exemplo n.º 29
0
 public static string priceText(Domains site, SubDomains subsite, double price) {
   switch (site) {
     case Domains.el:
     case Domains.sz:
     case Domains.cz: return price.ToString("C", Currency.kcCulture);
     //case Domains.com: return priceText(SubDomain.subDomainToCurr(subsite), price);
     default: throw new Exception("Missing code here");
   }
 }
Exemplo n.º 30
0
        /// <summary>
        /// Add Ip.
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="source"></param>
        /// <param name="domainSource"></param>
        public void AddIP(string ip, string source, string domainSource, int MaxRecursion, bool doptr)
        {
            ip = ip.Trim();

            if (isIPv6(ip))
            {
                ip = ParseIPV6(ip);
            }

            if (!Ips.Items.Any(I => I.Ip.ToLower() == ip.ToLower()))
            {
                if (isPublicIP(ip))
                {
                    var isInNetrange = Project.IsIpInNetrange(ip);

                    if (!isInNetrange)
                    {
                        var host = string.Empty;
                        try
                        {
                            host = Dns.GetHostEntry(ip).HostName;

                            if (Program.data.Project.LstNetRange.Count == 0)
                            {
                                if (Program.data.Project.Domain != null)
                                {
                                    if (!IsMainDomainOrAlternative(host))
                                    {
                                        if (Program.data.Project.AlternativeDomains.Select(S => host.Contains(S.ToString())).Count() == 0)
                                        {
                                            string[] arrDom = host.Split(new char[] { '.' });
                                            if (arrDom.Count() > 1)
                                            {
                                                string auxFinalDom = arrDom[arrDom.Length - 2] + "." + arrDom[arrDom.Length - 1];
                                                Program.data.Project.AlternativeDomains.Add(auxFinalDom);
                                                MessageBox.Show("IP address associated to " + Program.data.Project.Domain + " belongs to a Netrange of " + auxFinalDom + ". It is going to be added as an alternative domain.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }

                        if (IsMainDomainOrAlternative(host))
                        {
                            var netrange = Project.GetNetrange(ip);

                            if (netrange != null)
                            {
                                Project.LstNetRange.Add(netrange);
#if PLUGINS
                                Thread tPluginOnNetrange = new Thread(new ParameterizedThreadStart(Program.data.plugins.OnNewNetrange));
                                tPluginOnNetrange.IsBackground = true;
                                object[] oNetRange = new object[] { new object[] { netrange.from, netrange.to } };
                                tPluginOnNetrange.Start(oNetRange);
#endif

                                if (!Program.cfgCurrent.ScanNetranges255 || Project.GetIpsOfNetrange(netrange) <= 255)
                                {
                                    List <string> lstIps = netrange.GenerateIpsOfNetrange();
                                    Program.LogThis(new Log(Log.ModuleType.IPRangeSearch, "Netrange with " + lstIps.Count.ToString() + " IPs", Log.LogType.low));
                                    Thread tAddIps = new Thread(new ParameterizedThreadStart(AddIpListAsync));
                                    tAddIps.IsBackground = true;
                                    tAddIps.Priority     = ThreadPriority.Lowest;
                                    tAddIps.Start(lstIps);
                                }
                            }
                        }
                    }
                }

                var ipItem = new IPsItem(ip, source);
                Ips.Items.Add(ipItem);

                // OnNewIP
#if PLUGINS
                Thread tPluginOnIP = new Thread(new ParameterizedThreadStart(Program.data.plugins.OnNewIP));
                tPluginOnIP.IsBackground = true;

                object[] oIP = new object[] { new object[] { ip } };
                tPluginOnIP.Start(oIP);
#endif
                if (MaxRecursion <= 0)
                {
                    OnChangeEvent(null);
                    return;
                }

                List <string> domains;
                if (doptr)
                {
                    if (domainSource != null)
                    {
                        if (Program.cfgCurrent.UseAllDns)
                        {
                            domains = new List <string>();
                            List <string> dnsServers = DNSUtil.GetNSServer(resolver, domainSource, DNSUtil.GetLocalNSServer().First().ToString());

                            foreach (string dns in dnsServers)
                            {
                                OnLog(null, new EventsThreads.ThreadStringEventArgs(string.Format("Making reverse resolution to IP: {0} Using DNS server: {1}", ip, dns)));

                                foreach (var domain in DNSUtil.GetHostNames(resolver, ip, dns).Where(domain => !domains.Contains(domain)))
                                {
                                    domains.Add(domain);
                                }
                            }
                        }
                        else
                        {
                            var dnsserver = DNSUtil.GetNSServer(resolver, domainSource);
                            OnLog(null, new EventsThreads.ThreadStringEventArgs(string.Format("Making reverse resolution to IP: {0} Using DNS server: {1}", ip, dnsserver)));
                            domains = DNSUtil.GetHostNames(resolver, ip, dnsserver);
                        }
                    }
                    else
                    {
                        domains = DNSUtil.GetHostNames(resolver, ip);
                    }
                    foreach (var domain in domains)
                    {
                        AddResolution(domain, ip, string.Format("{0} > DNS reverse resolution [{1}]", GetIpSource(ip), domain), MaxRecursion - 1, Program.cfgCurrent, true);
                    }
                }
                OnChangeEvent(null);
            }
        }
Exemplo n.º 31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            intProfile   = 0;
            oWorkstation = new Workstations(intProfile, dsn);
            oRemote      = new Workstations(intProfile, dsnRemote);
            oUser        = new Users(intProfile, dsn);
            oVariable    = new Variables(intEnvironment);
            oOnDemand    = new OnDemand(intProfile, dsn);
            oForecast    = new Forecast(intProfile, dsn);
            oClass       = new Classes(intProfile, dsn);
            string strUsers = "";

            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                int     intWorkstation = Int32.Parse(Request.QueryString["id"]);
                DataSet ds             = oWorkstation.GetVirtual(intWorkstation);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    intStep   = Int32.Parse(ds.Tables[0].Rows[0]["step"].ToString());
                    intAnswer = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString());
                    intAsset  = Int32.Parse(ds.Tables[0].Rows[0]["assetid"].ToString());
                    intRemote = Int32.Parse(ds.Tables[0].Rows[0]["remoteid"].ToString());
                    int     intClass  = Int32.Parse(oForecast.GetAnswer(intAnswer, "classid"));
                    int     intDomain = Int32.Parse(ds.Tables[0].Rows[0]["domainid"].ToString());
                    Domains oDomain   = new Domains(intProfile, dsn);
                    lblDomain.Text = oDomain.Get(intDomain, "name");
                    intDomain      = Int32.Parse(oDomain.Get(intDomain, "environment"));
                    int intName = Int32.Parse(ds.Tables[0].Rows[0]["nameid"].ToString());
                    lblWorkstation.Text = oWorkstation.GetName(intName);
                    txtUser.Attributes.Add("onkeyup", "return AJAXTextBoxGet(this,'300','195','" + divAJAX.ClientID + "','" + lstAJAX.ClientID + "','" + hdnUser.ClientID + "','" + oVariable.URL() + "/frame/users.aspx',2);");
                    lstAJAX.Attributes.Add("ondblclick", "AJAXClickRow();");
                    DataSet dsAccounts = oWorkstation.GetAccountsVirtual(intAsset);
                    rptAccounts.DataSource = dsAccounts;
                    rptAccounts.DataBind();
                    foreach (RepeaterItem ri in rptAccounts.Items)
                    {
                        LinkButton _delete = (LinkButton)ri.FindControl("btnDelete");
                        _delete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this account?');");
                    }
                    foreach (DataRow drAccount in dsAccounts.Tables[0].Rows)
                    {
                        strUsers += oUser.GetName(Int32.Parse(drAccount["userid"].ToString())) + ";";
                    }
                    if (rptAccounts.Items.Count == 0)
                    {
                        lblNone.Visible = true;
                        btnSubmit.Attributes.Add("onclick", "alert('You must add at least one account or select the skip button');return false;");
                    }
                    if (oClass.IsProd(intClass))
                    {
                        panProduction.Visible = true;
                    }
                    else
                    {
                        panAdmin.Visible = true;
                    }
                }
            }
            else
            {
                btnAdd.Enabled    = false;
                btnSubmit.Enabled = false;
                btnSkip.Enabled   = false;
            }
            btnSkip.Enabled = false;
            //btnSkip.Attributes.Add("onclick", "return confirm('Are you sure you want to skip the account configuration process?');");
            btnAdd.Attributes.Add("onclick", "return ValidateHidden('" + hdnUser.ClientID + "','" + txtUser.ClientID + "','Please enter a username, first name or last name') && EnsureAccenture('" + hdnUser.ClientID + "','" + strUsers + "');");
            //btnAdd.Attributes.Add("onclick", "return ValidateHidden('" + hdnUser.ClientID + "','" + txtUser.ClientID + "','Please enter a username, first name or last name')" + (boolProduction == true ? " && EnsureAccenture('" + hdnUser.ClientID + "','" + strUsers + "')" : "") + ";");
            btnManager.Attributes.Add("onclick", "return OpenWindow('NEW_USER','');");
        }
Exemplo n.º 32
0
 protected override bool IsValidContent(HttpWebResponse response)
 {
     return(Domains.Any(d => response.ResponseUri.AbsoluteUri.StartsWith(d, StringComparison.OrdinalIgnoreCase)));
 }
Exemplo n.º 33
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Hide();
            this.packToolStripMenuItem.Image     = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.archive, ShareXResources.Theme.TextColor);
            this.unpackToolStripMenuItem.Image   = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.unarchive, ShareXResources.Theme.TextColor);
            this.testModsToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.vial_solid, ShareXResources.Theme.TextColor);
            this.launcherToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.launch, ShareXResources.Theme.TextColor);
            this.exitToolStripMenuItem.Image     = NativeMethods.GetNativeMenuItemImage(new IntPtr(NativeMethods.HBMMENU_POPUP_CLOSE), true);
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                _ = Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning())
            {
                _       = MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", false);
                closing = true;
            }
            else
            {
                this.elsDir = SettingsFile.SettingsJson.ElsDir;
                if (this.elsDir.Length < 1)
                {
                    _ = MessageManager.ShowInfo($"Welcome to Els_kom.{Environment.NewLine}Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops.{Environment.NewLine}Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", false);

                    // avoids an issue where more than 1 settings form can be opened at the same time.
                    if (this.settingsfrm == null && this.aboutfrm == null)
                    {
                        using (this.settingsfrm = new SettingsForm())
                        {
                            _ = this.settingsfrm.ShowDialog();
                        }

                        this.settingsfrm = null;
                    }
                }

                var komplugins = new GenericPluginLoader <IKomPlugin>().LoadPlugins("plugins", out var domains1, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Komplugins.AddRange(komplugins);
                var callbackplugins = new GenericPluginLoader <ICallbackPlugin>().LoadPlugins("plugins", out var domains2, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Callbackplugins.AddRange(callbackplugins);
                var encryptionplugins = new GenericPluginLoader <IEncryptionPlugin>().LoadPlugins("plugins", out var domains3, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Encryptionplugins.AddRange(encryptionplugins);
#if NET5_0_OR_GREATER
                Contexts.AddRange(domains1);
                Contexts.AddRange(domains2);
                Contexts.AddRange(domains3);
#else
                Domains.AddRange(domains1);
                Domains.AddRange(domains2);
                Domains.AddRange(domains3);
#endif
                if (!GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsMain ?? false)
                {
                    _ = MessageManager.ShowInfo("This branch is not the main branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into main.", "Info!", Convert.ToBoolean(SettingsFile.SettingsJson.UseNotifications));
                }

                if (GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsDirty ?? false)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                MessageManager.Icon = this.Icon;
                MessageManager.Text = this.Text;
                var pluginTypes = new List <Type>();
                pluginTypes.AddRange(KOMManager.Callbackplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Komplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Encryptionplugins.Select((x) => x.GetType()));
                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.SettingsJson.Sources.Source.ToArray(),
                    pluginTypes,
                    Els_kom_Main.ServiceProvider);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    _ = pluginUpdateCheck.ShowMessage;
                }

                MessageManager.Visible = true;
                this.Show();
                this.Activate();
            }
            else
            {
                SettingsFile.SettingsJson = null;
                this.aboutfrm?.Close();
                this.settingsfrm?.Close();
                this.Close();
            }
        }
Exemplo n.º 34
0
        public List <CompiledData> Extract(string pathFiles)
        {
            Console.WriteLine("Extracting Data ");

            char[] separator           = { ' ' };
            string separatorDomainCode = ".";
            string separatorFileName   = "-";
            int    viewCount           = 0;
            int    responseSize        = 0;
            int    found = 0;

            var compiledList = new List <CompiledData>();

            try
            {
                DirectoryInfo directorySelected = new DirectoryInfo(pathFiles);

                foreach (FileInfo fileToRead in directorySelected.GetFiles("*.*"))
                {
                    Console.WriteLine($"Working on File: {fileToRead.Name}");

                    var period   = fileToRead.FullName.Split(separatorFileName);
                    var allLines = File.ReadAllLines(fileToRead.FullName);
                    foreach (var currentLine in allLines)
                    {
                        var periodHour = period[2].Substring(0, 2);

                        string[] splitCurrentLine = currentLine.Split(separator);

                        var domainCode = splitCurrentLine[0];
                        var pageTitle  = splitCurrentLine[1];
                        viewCount    = Convert.ToInt32(splitCurrentLine[2]);
                        responseSize = Convert.ToInt32(splitCurrentLine[3]);
                        string language = null;
                        string domain   = null;

                        found = domainCode.IndexOf(separatorDomainCode);
                        if (found < 0)
                        {
                            language = splitCurrentLine[0];;
                            domain   = "Wikipedia";
                        }
                        else
                        {
                            string[] splitDomainCode = domainCode.Split(separatorDomainCode);
                            language = splitDomainCode.First();
                            var smallDomain = splitDomainCode.Last();
                            domain = Domains.Get().Where(x => x.GetCode() == smallDomain).FirstOrDefault().GetName();
                        }
                        var compiledData = new CompiledData(domainCode, language, domain, pageTitle, viewCount, responseSize, periodHour, currentLine);
                        compiledList.Add(compiledData);
                    }
                    ;
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex);
            }

            return(compiledList);
        }
Exemplo n.º 35
0
        public override IEmbed BuildEmbed()
        {
            var builder = base.BuildEmbed().ToEmbedBuilder();

            builder.WithAuthor(String.Format(DelveResources.CardThemeDomainTitleFormat,
                                             string.Join(DelveResources.ListSeperator, Themes.Select(t => t.DelveSiteTheme)),
                                             string.Join(DelveResources.ListSeperator, Domains.Select(d => d.DelveSiteDomain))));
            builder.WithTitle(String.Format(DelveResources.CardSiteNameFormat, SiteName));
            builder.WithDescription(SiteObjective);

            string riskText = string.Empty;

            if (Ticks <= 12)
            {
                riskText = DelveResources.RiskZoneLow;
            }
            else if (Ticks <= 28)
            {
                riskText = DelveResources.RiskZoneMedium;
            }
            else
            {
                riskText = DelveResources.RiskZoneHigh;
            }
            builder.AddField(DelveResources.RiskZoneField, riskText);

            return(builder.Build());
        }
Exemplo n.º 36
0
 public static string UrlLocalize(string url, Domains site, Langs lng) {
   if (site != Domains.com && site != Domains.org) return url;
   int idx = url.IndexOf("pages/"); if (idx < 0) return url;
   string key = url.Substring(idx);
   return url.Substring(0, idx) + Localize(key, lng.ToString().Replace('_', '-'));
 }
Exemplo n.º 37
0
        protected void btnApprove_Click(Object Sender, EventArgs e)
        {
            oResourceRequest.UpdateWorkflowHours(intResourceWorkflow);
            DataSet ds             = oGroupRequest.GetMaintenance(intRequest, intItem, intNumber);
            int     intUser        = oRequest.GetUser(intRequest);
            DataSet dsParameters   = oGroupRequest.GetMaintenanceParameters(intRequest, intItem, intNumber);
            string  strMaintenance = ds.Tables[0].Rows[0]["maintenance"].ToString();
            string  strGroup       = ds.Tables[0].Rows[0]["name"].ToString();
            int     intDomain      = Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString());
            Domains oDomain        = new Domains(intProfile, dsn);

            intDomain = Int32.Parse(oDomain.Get(intDomain, "environment"));
            AD             oAD       = new AD(intProfile, dsn, intDomain);
            Variables      oVariable = new Variables(intDomain);
            DirectoryEntry oEntry    = oAD.GroupSearch(strGroup);

            if (oEntry != null)
            {
                switch (strMaintenance)
                {
                case "MOVE":
                    // Group Move
                    string strPath = dsParameters.Tables[0].Rows[0]["value"].ToString();
                    oRequest.AddResult(intRequest, intItem, intNumber, "Group Move", oAD.MoveGroup(oEntry, strPath), "Group " + strGroup + " was successfully moved", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                    break;

                case "COPY":
                    // Group Copy
                    string strID     = txtID.Text;
                    string strScope2 = dsParameters.Tables[0].Rows[1]["value"].ToString();
                    if (strScope2 == "Domain Local")
                    {
                        strScope2 = "DLG";
                    }
                    if (strScope2 == "Global")
                    {
                        strScope2 = "GG";
                    }
                    if (strScope2 == "Universal")
                    {
                        strScope2 = "UG";
                    }
                    string strType2 = dsParameters.Tables[0].Rows[2]["value"].ToString();
                    if (strType2 == "Security")
                    {
                        strType2 = "S";
                    }
                    if (strType2 == "Distribution")
                    {
                        strType2 = "D";
                    }
                    oRequest.AddResult(intRequest, intItem, intNumber, "Group Copy", oAD.CreateGroup(strID, "", "Created by ClearView - " + DateTime.Now.ToShortDateString(), oVariable.GroupOU(), strScope2, strType2), "Group " + strGroup + " was successfully copied", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                    foreach (ListItem oList in chkUsers.Items)
                    {
                        if (oList.Selected == true)
                        {
                            oRequest.AddResult(intRequest, intItem, intNumber, "Group Membership", oAD.JoinGroup(oList.Value, strID, 0), "Account " + oList.Value + " was successfully added to the group " + strGroup, intEnvironment, (oService.Get(intService, "notify_client") == "1"), "");
                        }
                    }
                    break;

                case "DELETE":
                    // Group Deletion
                    oRequest.AddResult(intRequest, intItem, intNumber, "Group Deletion", oAD.Delete(oEntry), "Group " + strGroup + " was successfully deleted", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                    break;

                case "RENAME":
                    // Group Rename
                    string strI = txtID.Text;
                    oRequest.AddResult(intRequest, intItem, intNumber, "Group Rename", oAD.Rename(oEntry, strI, "", ""), "Group " + strGroup + " was successfully renamed", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                    break;

                case "CHANGE":
                    // Group Change
                    string strScope3 = dsParameters.Tables[0].Rows[0]["value"].ToString();
                    if (strScope3 == "Domain Local")
                    {
                        strScope3 = "DLG";
                    }
                    if (strScope3 == "Global")
                    {
                        strScope3 = "GG";
                    }
                    if (strScope3 == "Universal")
                    {
                        strScope3 = "UG";
                    }
                    string strType3 = dsParameters.Tables[0].Rows[1]["value"].ToString();
                    if (strType3 == "Security")
                    {
                        strType3 = "S";
                    }
                    if (strType3 == "Distribution")
                    {
                        strType3 = "D";
                    }
                    oRequest.AddResult(intRequest, intItem, intNumber, "Group Change", oAD.Change(oEntry, strScope3, strType3), "Group " + strGroup + " was successfully changed", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                    break;
                }
            }
            else if (strMaintenance == "CREATE")
            {
                // Group Creation
                string strScope1 = dsParameters.Tables[0].Rows[0]["value"].ToString();
                if (strScope1 == "Domain Local")
                {
                    strScope1 = "DLG";
                }
                if (strScope1 == "Global")
                {
                    strScope1 = "GG";
                }
                if (strScope1 == "Universal")
                {
                    strScope1 = "UG";
                }
                string strType1 = dsParameters.Tables[0].Rows[1]["value"].ToString();
                if (strType1 == "Security")
                {
                    strType1 = "S";
                }
                if (strType1 == "Distribution")
                {
                    strType1 = "D";
                }
                oRequest.AddResult(intRequest, intItem, intNumber, "Group Creation", oAD.CreateGroup(txtID.Text, "", "Created by ClearView - " + DateTime.Now.ToShortDateString(), oVariable.GroupOU(), strScope1, strType1), "Group " + strGroup + " was successfully created", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
            }
            oGroupRequest.UpdateMaintenance(intRequest, intItem, intNumber, 1, txtComments.Text);
            Complete();
        }
Exemplo n.º 38
0
        public JsonResult AddField(String Name, String FieldType, String Comment, String PossibleValues, String SelectText, String IsMandatory, String ShowInSignup, String SortValues, String IsActive, String AdminUseOnly, String VerticalLayout, int FieldGroupID, bool Encrypted, int[] SelectedDomains, int[] SelectedRoles)
        {
            ProfileField profileField = ProfileFields.GetByName(Name);
            String       Message      = "";

            if (profileField.FieldID > 0 && profileField.FieldName.Trim().ToLower() == Name.Trim().ToLower())
            {
                Message = "The field \"" + Name + "\" already exists.";
            }

            if (Name.Trim().ToLower().Length == 0)
            {
                Message = "The field name should not be empty.";
            }

            if (Message != "")
            {
                RequestResultModel _model = new RequestResultModel();
                _model.InfoType = RequestResultInfoType.ErrorOrDanger;
                _model.Message  = Message;

                AuditEvent.AppEventWarning(Profile.Member.Email, Message);

                return(Json(new
                {
                    NotifyType = NotifyType.DialogInline,
                    Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model),
                }, JsonRequestBehavior.AllowGet));
            }


            profileField.FieldName       = Name;
            profileField.Comment         = Comment;
            profileField.FieldTypeID     = (ProfileFieldTypeEnum)int.Parse(FieldType);
            profileField.PossibleValues  = PossibleValues;
            profileField.TextSelectValue = SelectText;
            profileField.IsMandatory     = (IsMandatory == "True" ? 1 : 0);
            profileField.ShowInSignUp    = (ShowInSignup == "True" ? 1 : 0);
            profileField.SortValues      = SortValues == "True" ? 1 : 0;
            profileField.IsActive        = IsActive == "True" ? 1 : 0;
            profileField.AdminUseOnly    = AdminUseOnly == "True" ? 1 : 0;
            profileField.VerticalLayout  = VerticalLayout == "True" ? 1 : 0;
            profileField.FieldGroupID    = FieldGroupID;
            profileField.Encrypted       = Encrypted == true ? 1 : 0;
            profileField.Save();

            if (SelectedDomains != null)
            {
                List <Domain> _domains = Domains.Get();
                foreach (Domain _domain in _domains)
                {
                    DomainProfileField _domainField = new DomainProfileField();
                    _domainField.DomainID       = _domain.DomainID;
                    _domainField.ProfileFieldID = profileField.FieldID;

                    if (SelectedDomains.Where(t => t == _domain.DomainID).FirstOrDefault() != default(int))
                    {
                        _domainField.Save();
                    }
                }
            }

            if (SelectedRoles != null)
            {
                List <Role> _roles = Web.Admin.Logic.Collections.Roles.Get();
                foreach (Role _role in _roles)
                {
                    RoleProfileField _roleField = new RoleProfileField();
                    _roleField.RoleID         = _role.RoleID;
                    _roleField.ProfileFieldID = profileField.FieldID;

                    if (SelectedRoles.Where(t => t == _role.RoleID).FirstOrDefault() != default(int))
                    {
                        _roleField.Save();
                    }
                }
            }

            AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format("The \"{0}\" field has been added.", Name));

            return(Json(new
            {
                NotifyType = -1,
                Html = "",
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile       = Int32.Parse(Request.Cookies["profileid"].Value);
            oFunction        = new Functions(intProfile, dsn, intEnvironment);
            oUser            = new Users(intProfile, dsn);
            oPage            = new Pages(intProfile, dsn);
            oResourceRequest = new ResourceRequest(intProfile, dsn);
            oRequestItem     = new RequestItems(intProfile, dsn);
            oRequest         = new Requests(intProfile, dsn);
            oApplication     = new Applications(intProfile, dsn);
            oGroupRequest    = new GroupRequest(intProfile, dsn);
            oDelegate        = new Delegates(intProfile, dsn);
            oService         = new Services(intProfile, dsn);
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "")
            {
                intPage = Int32.Parse(Request.QueryString["pageid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            string strAttributes  = "";
            bool   boolIncomplete = false;

            if (Request.QueryString["rrid"] != null && Request.QueryString["rrid"] != "")
            {
                intResourceWorkflow = Int32.Parse(Request.QueryString["rrid"]);
                intResourceParent   = oResourceRequest.GetWorkflowParent(intResourceWorkflow);
                DataSet ds = oResourceRequest.Get(intResourceParent);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    intRequest = Int32.Parse(ds.Tables[0].Rows[0]["requestid"].ToString());
                    intItem    = Int32.Parse(ds.Tables[0].Rows[0]["itemid"].ToString());
                    intNumber  = Int32.Parse(ds.Tables[0].Rows[0]["number"].ToString());
                    // Start Workflow Change
                    bool boolComplete = (oResourceRequest.GetWorkflow(intResourceWorkflow, "status") == "3");
                    int  intUser      = Int32.Parse(oResourceRequest.GetWorkflow(intResourceWorkflow, "userid"));
                    // End Workflow Change
                    intService = Int32.Parse(ds.Tables[0].Rows[0]["serviceid"].ToString());
                    int intApp = oRequestItem.GetItemApplication(intItem);

                    if (Request.QueryString["save"] != null && Request.QueryString["save"] != "")
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "saved", "<script type=\"text/javascript\">alert('Information Saved Successfully');<" + "/" + "script>");
                    }
                    if (oService.Get(intService, "sla") != "")
                    {
                        oFunction.ConfigureToolButton(btnSLA, "/images/tool_sla");
                        int intDays = oResourceRequest.GetSLA(intResourceParent);
                        if (intDays < 1)
                        {
                            btnSLA.Style["border"] = "solid 2px #FF0000";
                        }
                        else if (intDays < 3)
                        {
                            btnSLA.Style["border"] = "solid 2px #FF9999";
                        }
                        btnSLA.Attributes.Add("onclick", "return OpenWindow('RESOURCE_REQUEST_SLA','?rrid=" + intResourceParent.ToString() + "');");
                    }
                    else
                    {
                        btnSLA.ImageUrl = "/images/tool_sla_dbl.gif";
                        btnSLA.Enabled  = false;
                    }
                    if (!IsPostBack)
                    {
                        if (intResourceWorkflow > 0)
                        {
                            ds = oRequest.Get(intRequest);
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                ds = oGroupRequest.GetMaintenance(intRequest, intItem, intNumber);
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    if (ds.Tables[0].Rows[0]["completed"].ToString() == "")
                                    {
                                        boolIncomplete = true;
                                    }
                                    else
                                    {
                                        lblComplete.Text    = ds.Tables[0].Rows[0]["completed"].ToString();
                                        panComplete.Visible = true;
                                    }
                                    lblRequestBy.Text = oUser.GetFullName(oRequest.GetUser(intRequest));
                                    lblRequestOn.Text = DateTime.Parse(oRequest.Get(intRequest, "created")).ToLongDateString();
                                    int     intDomain = Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString());
                                    Domains oDomain   = new Domains(intProfile, dsn);
                                    intDomain = Int32.Parse(oDomain.Get(intDomain, "environment"));
                                    AD            oAD          = new AD(intProfile, dsn, intDomain);
                                    Variables     oVariable    = new Variables(intDomain);
                                    DataSet       dsParameters = oGroupRequest.GetMaintenanceParameters(intRequest, intItem, intNumber);
                                    StringBuilder sb           = new StringBuilder(strDetails);

                                    switch (ds.Tables[0].Rows[0]["maintenance"].ToString())
                                    {
                                    case "CREATE":
                                        lblType.Text = "Group Creation";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        panID.Visible = true;
                                        txtID.Text    = ds.Tables[0].Rows[0]["name"].ToString();
                                        sb.Append("<tr><td><b>Scope:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[0]["value"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Type:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[1]["value"].ToString());
                                        sb.Append("</td>");
                                        break;

                                    case "MOVE":
                                        lblType.Text = "Group Move";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>New Location:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[0]["value"].ToString());
                                        sb.Append("</td>");
                                        break;

                                    case "COPY":
                                        lblType.Text = "Group Copy";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        panID.Visible = true;
                                        txtID.Text    = dsParameters.Tables[0].Rows[0]["value"].ToString();
                                        sb.Append("<tr><td><b>Scope:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[1]["value"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Type:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[2]["value"].ToString());
                                        sb.Append("</td>");
                                        panUsers.Visible = true;
                                        string[] strUsers;
                                        char[]   strSplit = { ';' };
                                        strUsers = dsParameters.Tables[0].Rows[3]["value"].ToString().Split(strSplit);
                                        for (int ii = 0; ii < strUsers.Length; ii++)
                                        {
                                            if (strUsers[ii].Trim() != "")
                                            {
                                                DirectoryEntry oEntry2 = oAD.UserSearch(strUsers[ii].Trim());
                                                ListItem       oList   = new ListItem(oEntry2.Properties["displayName"].Value.ToString() + " (" + oEntry2.Properties["name"].Value.ToString() + ")", oEntry2.Properties["name"].Value.ToString());
                                                chkUsers.Items.Add(oList);
                                                oList.Selected = true;
                                            }
                                        }
                                        break;

                                    case "DELETE":
                                        lblType.Text = "Group Deletion";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        break;

                                    case "RENAME":
                                        lblType.Text = "Group Rename";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        panID.Visible = true;
                                        txtID.Text    = dsParameters.Tables[0].Rows[0]["value"].ToString();
                                        break;

                                    case "CHANGE":
                                        lblType.Text = "Group Properties Change";
                                        sb.Append("<tr><td><b>Group:</b></td><td>");
                                        sb.Append(ds.Tables[0].Rows[0]["name"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>Domain:</b></td><td>");
                                        sb.Append(oDomain.Get(Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString()), "name"));
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>New Scope:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[0]["value"].ToString());
                                        sb.Append("</td>");
                                        sb.Append("<tr><td><b>New Type:</b></td><td>");
                                        sb.Append(dsParameters.Tables[0].Rows[1]["value"].ToString());
                                        sb.Append("</td>");
                                        break;

                                    default:
                                        lblType.Text = "Unavailable";
                                        sb.Append("<tr><td colspan=\"2\"><b>Invalid Maintenance Code!</b></td>");
                                        break;
                                    }
                                    strDetails = sb.ToString();

                                    panWorkload.Visible = true;
                                }
                                else
                                {
                                    panDenied.Visible = true;
                                }
                            }
                            else
                            {
                                panDenied.Visible = true;
                            }
                        }
                        else
                        {
                            panDenied.Visible = true;
                        }
                    }
                }
                else
                {
                    panDenied.Visible = true;
                }

                btnDenied.Attributes.Add("onclick", "return CloseWindow();");
                oFunction.ConfigureToolButton(btnApprove, "/images/tool_approve");
                oFunction.ConfigureToolButton(btnDeny, "/images/tool_deny");
                if (boolIncomplete == true)
                {
                    btnApprove.Attributes.Add("onclick", "return " + strAttributes + "confirm('Are you sure you want to APPROVE this request?');");
                    btnDeny.Attributes.Add("onclick", "return ValidateText('" + txtComments.ClientID + "','Please enter a reason') && confirm('Are you sure you want to DENY this request?');");
                }
                else
                {
                    btnApprove.Attributes.Add("onclick", "alert('This request has already been completed.\\n\\nIf this request continues to appear in your work queue, please contact a ClearView administrator.');return false;");
                    btnDeny.Attributes.Add("onclick", "alert('This request has already been completed.\\n\\nIf this request continues to appear in your work queue, please contact a ClearView administrator.');return false;");
                }
                oFunction.ConfigureToolButton(btnPrint, "/images/tool_print");
                btnPrint.Attributes.Add("onclick", "return PrintWindow();");
                oFunction.ConfigureToolButton(btnClose, "/images/tool_close");
                btnClose.Attributes.Add("onclick", "return ExitWindow();");
                // 6/1/2009 - Load ReadOnly View
                if (oResourceRequest.CanUpdate(intProfile, intResourceWorkflow, false) == false)
                {
                    oFunction.ConfigureToolButtonRO(btnApprove, btnDeny);
                    //panDenied.Visible = true;
                }
            }
            else
            {
                panDenied.Visible = true;
            }
        }
Exemplo n.º 40
0
        private bool LoadInformation(int _request_workflow)
        {
            if (intProject > 0)
            {
                lblName.Text   = oProject.Get(intProject, "name");
                lblNumber.Text = oProject.Get(intProject, "number");
                lblType.Text   = "Project";
            }
            else
            {
                lblName.Text   = oResourceRequest.GetWorkflow(_request_workflow, "name");
                lblNumber.Text = "CVT" + intRequest.ToString();
                lblType.Text   = "Task";
            }
            bool    boolDone = false;
            DataSet ds       = oOnDemandTasks.GetVMWareII(intRequest, intItem, intNumber);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Forecast oForecast = new Forecast(intProfile, dsn);
                int      intAnswer = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString());
                if (oForecast.IsHARoom(intAnswer) == true)
                {
                    DataSet dsServer = oServer.GetAnswer(intAnswer);
                    foreach (DataRow drServer in dsServer.Tables[0].Rows)
                    {
                        int     intHA = Int32.Parse(drServer["id"].ToString());
                        DataSet dsHA  = oServer.GetHA(intHA);
                        if (dsHA.Tables[0].Rows.Count > 0)
                        {
                            if (lblHA.Text != "")
                            {
                                lblHA.Text += "<br/>";
                            }
                            lblHA.Text   += oServer.GetName(intHA, true) + " = " + oServer.GetName(Int32.Parse(dsHA.Tables[0].Rows[0]["serverid_ha"].ToString()), true);
                            panHA.Visible = true;
                        }
                    }
                }
                lblAnswer.Text = intAnswer.ToString();
                btnView.Attributes.Add("onclick", "return OpenWindow('FORECAST_EQUIPMENT','?id=" + intAnswer.ToString() + "');");
                btnBirth.Attributes.Add("onclick", "return OpenWindow('PDF_BIRTH','?id=" + intAnswer.ToString() + "');");
                btnSC.Attributes.Add("onclick", "return OpenWindow('PDF_BIRTH','?id=" + intAnswer.ToString() + "');");
                lblView.Text = oOnDemandTasks.GetBody(intAnswer, intImplementorDistributed, intImplementorMidrange);
                int intModel = Int32.Parse(ds.Tables[0].Rows[0]["modelid"].ToString());
                ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn);
                intModel = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                Models oModel     = new Models(intProfile, dsn);
                int    intType    = Int32.Parse(oModel.Get(intModel, "typeid"));
                Types  oType      = new Types(intProfile, dsn);
                string strExecute = oType.Get(intType, "forecast_execution_path");
                if (strExecute != "")
                {
                    btnExecute.Attributes.Add("onclick", "return OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + intAnswer.ToString() + "');");
                }
                chk1.Checked  = (ds.Tables[0].Rows[0]["chk1"].ToString() == "1");
                chk3.Checked  = (ds.Tables[0].Rows[0]["chk3"].ToString() == "1");
                chk4.Checked  = (ds.Tables[0].Rows[0]["chk4"].ToString() == "1");
                chk5.Checked  = (ds.Tables[0].Rows[0]["chk5"].ToString() == "1");
                chk6.Checked  = (ds.Tables[0].Rows[0]["chk6"].ToString() == "1");
                chk7.Checked  = (ds.Tables[0].Rows[0]["chk7"].ToString() == "1");
                chk8.Checked  = (ds.Tables[0].Rows[0]["chk8"].ToString() == "1");
                chk9.Checked  = (ds.Tables[0].Rows[0]["chk9"].ToString() == "1");
                chk10.Checked = (ds.Tables[0].Rows[0]["chk10"].ToString() == "1");
                chk11.Checked = (ds.Tables[0].Rows[0]["chk11"].ToString() == "1");
                int intNotifications = Int32.Parse(ds.Tables[0].Rows[0]["notifications"].ToString());
                int intClass         = Int32.Parse(oForecast.GetAnswer(intAnswer, "classid"));

                if (oClass.Get(intClass, "prod") != "1")
                {
                    chk9.Checked   = true;
                    img9.ImageUrl  = "/images/cancel.gif";
                    chk10.Checked  = true;
                    img10.ImageUrl = "/images/cancel.gif";
                    chk11.Checked  = true;
                    img11.ImageUrl = "/images/cancel.gif";
                }
                boolDone = (chk1.Checked && chk3.Checked && chk4.Checked && chk5.Checked && chk6.Checked && chk7.Checked && chk8.Checked && chk9.Checked && chk10.Checked && chk11.Checked);

                img1.ImageUrl = "/images/green_arrow.gif";
                if (chk1.Checked == true)
                {
                    btnExecute.Enabled = false;
                    img1.ImageUrl      = "/images/check.gif";
                    img3.ImageUrl      = "/images/green_arrow.gif";
                    chk3.Enabled       = true;
                    Servers oServer  = new Servers(intProfile, dsn);
                    DataSet dsAnswer = oServer.GetAnswer(intAnswer);
                    foreach (DataRow drAnswer in dsAnswer.Tables[0].Rows)
                    {
                        if (lbl1.Text != "")
                        {
                            lbl1.Text += "<br/>";
                        }
                        int        intServer     = Int32.Parse(drAnswer["id"].ToString());
                        int        intServerName = Int32.Parse(drAnswer["nameid"].ToString());
                        ServerName oServerName   = new ServerName(0, dsn);
                        string     strName       = oServer.GetName(intServer, boolUsePNCNaming);
                        lbl1.Text += "Server Name: " + strName + "<br/>";
                        Zeus    oZeus  = new Zeus(intProfile, dsnZeus);
                        DataSet dsZeus = oZeus.GetBuildServer(intServer);
                        if (dsZeus.Tables[0].Rows.Count > 0)
                        {
                            lbl1.Text += "Serial Number: " + dsZeus.Tables[0].Rows[0]["serial"].ToString() + "<br/>";
                            lbl1.Text += "Asset Tag: " + dsZeus.Tables[0].Rows[0]["asset"].ToString() + "<br/>";
                        }
                        int     intDomain = Int32.Parse(drAnswer["domainid"].ToString());
                        Domains oDomain   = new Domains(intProfile, dsn);
                        boolMove = (oDomain.Get(intDomain, "move") == "1");
                        if (boolMove == true)
                        {
                            lbl1.Text += "DHCP Address: " + drAnswer["dhcp"].ToString() + "<br/>";
                        }
                        int         intIPAddress = 0;
                        IPAddresses oIPAddresses = new IPAddresses(0, dsnIP, dsn);
                        lbl1.Text += "Assigned IP Address: " + oServer.GetIPs(intServer, 1, 0, 0, dsnIP, "", "") + "<br/>";
                        lbl1.Text += "Final IP Address: " + oServer.GetIPs(intServer, 0, 1, 0, dsnIP, "", "") + "<br/>";
                        Asset  oAsset   = new Asset(intProfile, dsnAsset);
                        VMWare oVMWare  = new VMWare(intProfile, dsn);
                        int    intAsset = 0;
                        if (drAnswer["assetid"].ToString() != "")
                        {
                            intAsset = Int32.Parse(drAnswer["assetid"].ToString());
                        }
                        if (intAsset > 0)
                        {
                            DataSet dsGuest = oVMWare.GetGuest(strName);
                            if (dsGuest.Tables[0].Rows.Count > 0)
                            {
                                int intHost       = Int32.Parse(dsGuest.Tables[0].Rows[0]["hostid"].ToString());
                                int intCluster    = Int32.Parse(oVMWare.GetHost(intHost, "clusterid"));
                                int intFolder     = Int32.Parse(oVMWare.GetCluster(intCluster, "folderid"));
                                int intDataCenter = Int32.Parse(oVMWare.GetFolder(intFolder, "datacenterid"));
                                lbl1.Text += "DataCenter: " + oVMWare.GetDatacenter(intDataCenter, "name") + "<br/>";
                                lbl1.Text += "Host: " + oVMWare.GetHost(intHost, "name") + "<br/>";
                                int intDatastore = Int32.Parse(dsGuest.Tables[0].Rows[0]["datastoreid"].ToString());
                                lbl1.Text += "DataStore: " + oVMWare.GetDatastore(intDatastore, "name") + "<br/>";
                                int intPool = Int32.Parse(dsGuest.Tables[0].Rows[0]["poolid"].ToString());
                                //lbl1.Text += "Pool: " + oVMWare.GetPool(intPool, "name") + "<br/>";
                                int intVlan = Int32.Parse(dsGuest.Tables[0].Rows[0]["vlanid"].ToString());
                                lbl1.Text += "VLAN: " + oVMWare.GetVlan(intVlan, "name") + "<br/>";
                            }
                        }
                        Storage       oStorage      = new Storage(intProfile, dsn);
                        int           intCluster2   = Int32.Parse(drAnswer["clusterid"].ToString());
                        int           intCSMConfig2 = Int32.Parse(drAnswer["csmconfigid"].ToString());
                        int           intNumber2    = Int32.Parse(drAnswer["number"].ToString());
                        DataSet       dsLuns        = oStorage.GetLuns(intAnswer, 0, intCluster2, intCSMConfig2, intNumber2);
                        StringBuilder sbStorage     = new StringBuilder();
                        int           intRow        = 0;
                        bool          boolOverride  = (oForecast.GetAnswer(intAnswer, "storage_override") == "1");
                        foreach (DataRow drLun in dsLuns.Tables[0].Rows)
                        {
                            intRow++;
                            sbStorage.Append("<tr>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(intRow.ToString());
                            sbStorage.Append("</td>");
                            string strLetter = drLun["letter"].ToString();
                            if (strLetter == "")
                            {
                                if (drLun["driveid"].ToString() == "-1000")
                                {
                                    strLetter = "E";
                                }
                                else if (drLun["driveid"].ToString() == "-100")
                                {
                                    strLetter = "F";
                                }
                                else if (drLun["driveid"].ToString() == "-10")
                                {
                                    strLetter = "P";
                                }
                                else if (drLun["driveid"].ToString() == "-1")
                                {
                                    strLetter = "Q";
                                }
                            }
                            if ((boolOverride == true && drLun["driveid"].ToString() == "0") || oForecast.IsOSMidrange(intAnswer) == true)
                            {
                                sbStorage.Append("<td>");
                                sbStorage.Append(drLun["path"].ToString());
                                sbStorage.Append("</td>");
                            }
                            else
                            {
                                sbStorage.Append("<td>");
                                sbStorage.Append(strLetter);
                                sbStorage.Append(":");
                                sbStorage.Append(drLun["path"].ToString());
                                sbStorage.Append("</td>");
                            }
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["performance"].ToString());
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["size"].ToString());
                            sbStorage.Append(" GB</td>");
                            sbStorage.Append("<td class=\"required\">");
                            sbStorage.Append(drLun["actual_size"].ToString() == "-1" ? "Pending" : drLun["actual_size"].ToString() + " GB");
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["size_qa"].ToString());
                            sbStorage.Append(" GB</td>");
                            sbStorage.Append("<td class=\"required\">");
                            sbStorage.Append(drLun["actual_size_qa"].ToString() == "-1" ? "Pending" : drLun["actual_size_qa"].ToString() + " GB");
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["size_test"].ToString());
                            sbStorage.Append(" GB</td>");
                            sbStorage.Append("<td class=\"required\">");
                            sbStorage.Append(drLun["actual_size_test"].ToString() == "-1" ? "Pending" : drLun["actual_size_test"].ToString() + " GB");
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["replicated"].ToString() == "0" ? "No" : "Yes");
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td class=\"required\">");
                            sbStorage.Append(drLun["actual_replicated"].ToString() == "-1" ? "Pending" : (drLun["actual_replicated"].ToString() == "0" ? "No" : "Yes"));
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td>");
                            sbStorage.Append(drLun["high_availability"].ToString() == "0" ? "No" : "Yes (" + drLun["size"].ToString() + " GB)");
                            sbStorage.Append("</td>");
                            sbStorage.Append("<td class=\"required\">");
                            sbStorage.Append(drLun["actual_high_availability"].ToString() == "-1" ? "Pending" : (drLun["actual_high_availability"].ToString() == "0" ? "No" : "Yes (" + drLun["actual_size"].ToString() + " GB)"));
                            sbStorage.Append("</td>");
                            sbStorage.Append("</tr>");
                            DataSet dsPoints = oStorage.GetMountPoints(Int32.Parse(drLun["id"].ToString()));
                            int     intPoint = 0;
                            foreach (DataRow drPoint in dsPoints.Tables[0].Rows)
                            {
                                intRow++;
                                intPoint++;
                                sbStorage.Append("<tr>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(intRow.ToString());
                                sbStorage.Append("</td>");
                                if (oForecast.IsOSMidrange(intAnswer) == true)
                                {
                                    sbStorage.Append("<td>");
                                    sbStorage.Append(drPoint["path"].ToString());
                                    sbStorage.Append("</td>");
                                }
                                else
                                {
                                    sbStorage.Append("<td>");
                                    sbStorage.Append(strLetter);
                                    sbStorage.Append(":\\SH");
                                    sbStorage.Append(drLun["driveid"].ToString());
                                    sbStorage.Append("VOL");
                                    sbStorage.Append(intPoint < 10 ? "0" : "");
                                    sbStorage.Append(intPoint.ToString());
                                    sbStorage.Append("</td>");
                                }
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["performance"].ToString());
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["size"].ToString());
                                sbStorage.Append(" GB</td>");
                                sbStorage.Append("<td class=\"required\">");
                                sbStorage.Append(drPoint["actual_size"].ToString() == "-1" ? "Pending" : drPoint["actual_size"].ToString() + " GB");
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["size_qa"].ToString());
                                sbStorage.Append(" GB</td>");
                                sbStorage.Append("<td class=\"required\">");
                                sbStorage.Append(drPoint["actual_size_qa"].ToString() == "-1" ? "Pending" : drPoint["actual_size_qa"].ToString() + " GB");
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["size_test"].ToString());
                                sbStorage.Append(" GB</td>");
                                sbStorage.Append("<td class=\"required\">");
                                sbStorage.Append(drPoint["actual_size_test"].ToString() == "-1" ? "Pending" : drPoint["actual_size_test"].ToString() + " GB");
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["replicated"].ToString() == "0" ? "No" : "Yes");
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td class=\"required\">");
                                sbStorage.Append(drPoint["actual_replicated"].ToString() == "-1" ? "Pending" : (drPoint["actual_replicated"].ToString() == "0" ? "No" : "Yes"));
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td>");
                                sbStorage.Append(drPoint["high_availability"].ToString() == "0" ? "No" : "Yes (" + drPoint["size"].ToString() + " GB)");
                                sbStorage.Append("</td>");
                                sbStorage.Append("<td class=\"required\">");
                                sbStorage.Append(drPoint["actual_high_availability"].ToString() == "-1" ? "Pending" : (drPoint["actual_high_availability"].ToString() == "0" ? "No" : "Yes (" + drPoint["actual_size"].ToString() + " GB)"));
                                sbStorage.Append("</td>");
                                sbStorage.Append("</tr>");
                            }
                        }
                        if (sbStorage.ToString() != "")
                        {
                            sbStorage.Insert(0, "<tr class=\"bold\"><td></td><td>Path</td><td>Performance</td><td>Requested<br/>Size in Prod</td><td>Actual<br/>Size in Prod</td><td>Requested<br/>Size in QA</td><td>Actual<br/>Size in QA</td><td>Requested<br/>Size in Test</td><td>Actual<br/>Size in Test</td><td>Requested<br/>Replication</td><td>Actual<br/>Replication</td><td>Requested<br/>High Availability</td><td>Actual<br/>High Availability</td></tr>");
                            sbStorage.Insert(0, "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\">");
                            sbStorage.Append("</table>");
                        }
                        lbl1.Text += sbStorage.ToString();
                    }
                }
                if (chk3.Checked == true)
                {
                    img3.ImageUrl = "/images/check.gif";
                    img4.ImageUrl = "/images/green_arrow.gif";
                    chk4.Enabled  = true;
                }
                if (chk4.Checked == true)
                {
                    img4.ImageUrl = "/images/check.gif";
                    if (boolMove == true)
                    {
                        img5.ImageUrl = "/images/green_arrow.gif";
                        chk5.Enabled  = true;
                    }
                    else
                    {
                        chk5.Checked  = true;
                        img7.ImageUrl = "/images/green_arrow.gif";
                        chk7.Enabled  = true;
                    }
                }
                if (chk5.Checked == true)
                {
                    if (boolMove == true)
                    {
                        img5.ImageUrl = "/images/check.gif";
                    }
                    else
                    {
                        img5.ImageUrl = "/images/cancel.gif";
                    }
                    if (boolMove == true)
                    {
                        img6.ImageUrl = "/images/green_arrow.gif";
                        chk6.Enabled  = true;
                    }
                }
                if (chk6.Checked == true)
                {
                    if (boolMove == true)
                    {
                        img6.ImageUrl = "/images/check.gif";
                    }
                    else
                    {
                        img6.ImageUrl = "/images/cancel.gif";
                    }
                    if (boolMove == true)
                    {
                        img7.ImageUrl = "/images/green_arrow.gif";
                        chk7.Enabled  = true;
                    }
                }
                if (chk7.Checked == true)
                {
                    img7.ImageUrl = "/images/check.gif";
                    img8.ImageUrl = "/images/green_arrow.gif";
                    chk8.Enabled  = true;
                }
                if (chk8.Checked == true)
                {
                    img8.ImageUrl = "/images/check.gif";
                    img9.ImageUrl = "/images/green_arrow.gif";
                    chk9.Enabled  = true;
                }
                if (chk9.Checked == true)
                {
                    img9.ImageUrl  = "/images/check.gif";
                    img10.ImageUrl = "/images/green_arrow.gif";
                    chk10.Enabled  = true;
                }
                if (chk10.Checked == true)
                {
                    img10.ImageUrl = "/images/check.gif";
                    img11.ImageUrl = "/images/green_arrow.gif";
                    chk11.Enabled  = true;
                }
                if (chk11.Checked == true)
                {
                    img11.ImageUrl = "/images/check.gif";
                }
            }
            if (Request.QueryString["div"] != null)
            {
                switch (Request.QueryString["div"])
                {
                case "E":
                    boolExecution = true;
                    break;
                }
            }
            if (boolDetails == false && boolExecution == false)
            {
                boolDetails = true;
            }
            return(boolDone);
        }
Exemplo n.º 41
0
        public List <string> GetDomainNames(X509Certificate2 certificate)
        {
            List <string> domainNames = new List <string>();

            if (!String.IsNullOrEmpty(Domains))
            {
                var domains = Domains.Split(',');

                List <string> trimmedDomains = new List <string>();

                foreach (var domain in domains)
                {
                    var d = domain.Trim();

                    if (d.Length > 0)
                    {
                        trimmedDomains.Add(d);
                    }
                }

                if (trimmedDomains.Count > 0)
                {
                    return(trimmedDomains);
                }
            }

            if (DiscoveryUrl != null)
            {
                foreach (var discoveryUrl in DiscoveryUrl)
                {
                    if (Uri.IsWellFormedUriString(discoveryUrl, UriKind.Absolute))
                    {
                        string name = new Uri(discoveryUrl).DnsSafeHost;

                        if (name == "localhost")
                        {
                            name = Utils.GetHostName();
                        }

                        bool found = false;

                        //domainNames.Any(n => String.Compare(n, name, StringComparison.OrdinalIgnoreCase) == 0);
                        foreach (var domainName in domainNames)
                        {
                            if (String.Compare(domainName, name, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            domainNames.Add(name);
                        }
                    }
                }
            }

            if (domainNames != null && domainNames.Count > 0)
            {
                return(domainNames);
            }

            if (certificate != null)
            {
                var names = Utils.GetDomainsFromCertficate(certificate);

                if (names != null && names.Count > 0)
                {
                    domainNames.AddRange(names);
                    return(domainNames);
                }

                var fields = Utils.ParseDistinguishedName(certificate.Subject);

                string name = null;

                foreach (var field in fields)
                {
                    if (field.StartsWith("DC=", StringComparison.Ordinal))
                    {
                        if (name != null)
                        {
                            name += ".";
                        }

                        name += field.Substring(3);
                    }
                }

                if (names != null)
                {
                    domainNames.AddRange(names);
                    return(domainNames);
                }
            }

            domainNames.Add(Utils.GetHostName());
            return(domainNames);
        }
Exemplo n.º 42
0
        public ILogger SendEmail(string email = null)
        {
            var emailDetails = new EmailDetails
            {
                FromEmail = string.IsNullOrEmpty(BrandingDictionary["Email"]) ? ConfigurationManager.AppSettings["smtpEmail"] : BrandingDictionary["Email"],
                ToEmails  = string.IsNullOrEmpty(email)
                               ? new List <string> {
                    ConfigurationManager.AppSettings["toEmail"], BrandingDictionary["Email"]
                }
                               : new List <string> {
                    email
                },
                Attachment = curlDetails.AttemptsFile
            };

            if (curlDetails.SessionId == 0)
            {
                Index++;
                emailDetails.Subject = $"Session Id error. for {BrandingDictionary["Company"]}";
                emailDetails.Body    = $"Hi {BrandingDictionary["FirstName"]}" +
                                       "Session Id was not retrieved from your servers. Please check your settings." + Environment.NewLine +
                                       $"Login:\t{curlDetails.MainUrl}" + Environment.NewLine +
                                       $"User: \t{curlDetails.Username}" + Environment.NewLine +
                                       "Method:\t POST";

                emailProcessor.SendEmail(emailDetails, BrandingDictionary);
                if (emailProcessor.IsSent)
                {
                    logger.Success = $"{Index}:\tEmails sent to {string.Join(" ", emailDetails.ToEmails)} for '{curlDetails.DomainId}' domain.\n";
                }
                else
                {
                    logger.Error = $"{Index}:\tEmails were not sent to {string.Join(" ", emailDetails.ToEmails)} for '{curlDetails.DomainId}' domain.\n";
                }
            }
            else if (!DomainsWithFiles.Any())
            {
                var topLevels = Domains.Where(domain => domain.IsTopLevel()).ToList();
                foreach (var topLevel in topLevels)
                {
                    var attempts = curlDetails.Attempts[topLevel.AdmtiveDomainId];
                    Index++;
                    if (Constants.EVEN.Contains(attempts))
                    {
                        emailDetails.Subject = $"Even attempt was done to download file for {BrandingDictionary["Company"]}";
                        emailDetails.Body    = $"Hi {BrandingDictionary["FirstName"]}" +
                                               "Downloading attempts are recorded in attached file.Please check your settings." + Environment.NewLine +
                                               $"Url: \t{curlDetails.DomainUrl}" + Environment.NewLine +
                                               $"User:\t{curlDetails.Username}" + Environment.NewLine;

                        File.AppendAllText(curlDetails.AttemptsFile, Constants.EMAIL_SENT_MESSAGE);
                        emailProcessor.SendEmail(emailDetails, BrandingDictionary);
                        if (emailProcessor.IsSent)
                        {
                            logger.Success = $"{Index}:\tEmails sent to {string.Join(" ", emailDetails.ToEmails)} for '{curlDetails.DomainId}' domain.\n";
                        }
                        else
                        {
                            logger.Error = $"{Index}:\tEmails were not sent to {string.Join(" ", emailDetails.ToEmails)} for '{curlDetails.DomainId}' domain.\n";
                        }
                    }
                    if (Constants.ODD.Contains(attempts))
                    {
                        logger.Error = $"{Index}:\tNo emails is about to be send for '{curlDetails.DomainId}' domain.\n";
                    }
                }
            }
            else
            {
                Index++;
                logger.Error = $"{Index}:\tNo emails needs to be send for '{curlDetails.DomainId}' domain.\n";
            }


            var state = GetLoggerState();

            logger.AddLog(state);
            return(logger);
        }
Exemplo n.º 43
0
 private void AddDomain()
 {
     Domains.Add(new DomainViewModel(new Domain().Default(DateTime.Now, Guid.NewGuid().ToString().ToLower())));
 }
Exemplo n.º 44
0
 public Domain GetDomain(string name)
 {
     return(Domains.SingleOrDefault(d => string.Equals(d.Name, name, System.StringComparison.OrdinalIgnoreCase)));
 }
Exemplo n.º 45
0
 IEnumerable<LineIds> getLines(Domains site) {
   foreach (LineIds line in comLines) yield return line;
   if (site == Domains.sz) yield return LineIds.Ucto;
 }