public bool SaveString(string value, string resourceid, string containerName, string directoryPath)
        {
            // Retrieve a reference to a container
            CloudBlobContainer container = blobClient.GetContainerReference(containerName);
            CloudBlobDirectory dir       = container.GetDirectoryReference(directoryPath);

            // Create the container if it doesn't already exist
            container.CreateIfNotExist();
            container.SetPermissions(new BlobContainerPermissions {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });

            try
            {
                CloudBlob stringblob = dir.GetBlobReference(resourceid);

                string guid = ShortGuidGenerator.NewGuid();

                stringblob.UploadText(value);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
 public ActionResult Index(IEnumerable <string> firstname, IEnumerable <string> lastname, IEnumerable <string> email)
 {
     if (AuthTokens[0] == "demo")
     {
         ViewBag.DemoNextStep = NextStep("!");
         return(View());
     }
     if (firstname != null && lastname != null && email != null)
     {
         if (firstname.Count() == lastname.Count() && firstname.Count() == email.Count())
         {
             CounselorInviteClient cic   = new CounselorInviteClient();
             AdminAccountClient    aac   = new AdminAccountClient();
             UserAccountClient     uac   = new UserAccountClient();
             AdminAccount          admin = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower());
             UserAccount           user  = uac.GetByPartitionAndRowKey(UserAccountClient.GetPartitionKeyForEmail(AuthTokens[1].ToLower()), AuthTokens[1].ToLower());
             string school = admin.School;
             for (var i = 0; i < firstname.Count(); i++)
             {
                 string emailLower = email.ElementAt(i).ToLower();
                 string guid       = ShortGuidGenerator.NewGuid();
                 cic.AddNewItem(new CounselorInvite {
                     FirstName = firstname.ElementAt(i), LastName = lastname.ElementAt(i), Email = emailLower, School = school, RowKey = guid
                 });
                 SendInviteEmail(email.ElementAt(i).ToLower(), firstname.ElementAt(i) + " " + lastname.ElementAt(i), user.FirstName + " " + user.LastName, guid);
             }
             return(View());
         }
     }
     ViewBag.ErrorMessage = "error";
     return(View());
 }
        public HttpResponse CreateGroup(string school, string counselor, string groupname, string year, string grade)
        {
            if (AuthTokens[0] == "demo")
            {
                Response.ContentType = "application/json";
                Response.Write("{\"result\": \"ok\", \"pincode\": \"demo1\", \"url\": \"demo\"}");
                Response.End();
                return(null);
            }
            string response;
            string pincode = getUniquePinCode(school);
            string guid    = ShortGuidGenerator.NewGuid();

            AccessCodeClient acc = new AccessCodeClient();

            acc.AddNewItem(new AccessCode {
                RowKey = guid, Code = pincode, Counselor = counselor, Grade = grade, School = school, Year = year, GroupName = groupname
            });

            //AssessmentGroupClient agc = new AssessmentGroupClient();
            //AssessmentGroupPinCodeClient agpcc = new AssessmentGroupPinCodeClient();
            //agc.AddNewItem(new AssessmentGroup { PartitionKey = school, RowKey = pincode, Teacher = teacher, Group = group });
            //agpcc.AddNewItem(new AssessmentGroupPinCode { RowKey = guid, PinCode = pincode, School = school, Teacher = teacher, Group = group });
            response             = "{\"result\": \"ok\", \"pincode\": \"" + pincode + "\", \"url\": \"" + guid + "\"}";
            Response.ContentType = "application/json";
            Response.Write(response);
            Response.End();
            return(null);
        }
 public ActionResult Groups(IEnumerable <string> year, IEnumerable <string> grade, IEnumerable <string> counselor, IEnumerable <string> groupname)
 {
     if (AuthTokens[0] == "demo")
     {
         ViewBag.DemoNextStep = NextStep("!");
         return(View());
     }
     if (year != null && grade != null && counselor != null && groupname != null)
     {
         if (year.Count() == grade.Count() && year.Count() == counselor.Count() && year.Count() == groupname.Count())
         {
             AdminAccountClient aac    = new AdminAccountClient();
             AccessCodeClient   acc    = new AccessCodeClient();
             AdminAccount       admin  = aac.GetByPartitionAndRowKey("admin", AuthTokens[1].ToLower());
             string             school = admin.School;
             for (var i = 0; i < year.Count(); i++)
             {
                 acc.AddNewItem(new AccessCode {
                     RowKey = ShortGuidGenerator.NewGuid(), Code = PinCodeGenerator.NewPin(), Year = year.ElementAt(i), Grade = grade.ElementAt(i), Counselor = counselor.ElementAt(i), GroupName = groupname.ElementAt(i), School = school
                 });
             }
             ViewBag.CurrentYear = AccessCodeClient.CurrentGradYear();
             return(View());
         }
     }
     ViewBag.ErrorMessage = "error";
     ViewBag.CurrentYear  = AccessCodeClient.CurrentGradYear();
     return(View());
 }
示例#5
0
        public SiteVisit()
        {
            DateTime t = EasternTimeConverter.Convert(DateTime.UtcNow);

            PartitionKey = t.ToString("yyyyMMdd");
            RowKey       = ShortGuidGenerator.NewGuid();
        }
 public ActionResult Index(IEnumerable <string> year, IEnumerable <string> grade, IEnumerable <string> groupname)
 {
     if (AuthTokens[0] == "demo")
     {
         return(View());
     }
     if (year != null && grade != null && groupname != null)
     {
         if (year.Count() == grade.Count() && year.Count() == groupname.Count())
         {
             string counselor               = AuthTokens[1].ToLower();
             CounselorAccountClient cac     = new CounselorAccountClient();
             AccessCodeClient       acc     = new AccessCodeClient();
             CounselorAccount       account = cac.GetByPartitionAndRowKey("counselor", counselor);
             string school = account.School;
             for (var i = 0; i < year.Count(); i++)
             {
                 acc.AddNewItem(new AccessCode {
                     RowKey = ShortGuidGenerator.NewGuid(), Code = PinCodeGenerator.NewPin(), Year = year.ElementAt(i), Grade = grade.ElementAt(i), Counselor = counselor, GroupName = groupname.ElementAt(i), School = school
                 });
             }
             return(RedirectToAction("Index"));
         }
     }
     TempData["error"] = true;
     return(RedirectToAction("Index"));
 }
        private object createDropdownOption(XmlNode node)
        {
            StringBuilder cssclass = new StringBuilder();

            string campuskey = node.E("campus");

            if (campuskey != "")
            {
                string targetCssClass = "ddo_ckeq_" + campuskey.FormatAsProgrammaticId();
                cssclass.Append(" " + targetCssClass);
                addControlEvent("campus_key", "=", campuskey, targetCssClass, "show", "hide");
            }
            string programkey = node.E("program");

            if (programkey != "")
            {
                string targetCssClass = "ddo_pkeq_" + programkey.FormatAsProgrammaticId();
                cssclass.Append(" " + targetCssClass);
                addControlEvent("program_key", "=", programkey, targetCssClass, "show", "hide");
            }
            string gtvalue = node.E("geotargeting");

            if (gtvalue != "")
            {
                string targetCssClass = "ddo_geo_" + ShortGuidGenerator.NewGuid();
                cssclass.Append(" " + targetCssClass);
                addControlEvent("zip", "in", gtvalue, targetCssClass, "show", "hide");
                addControlEvent("state", "in", gtvalue, targetCssClass, "show", "hide");
            }

            return(new { label = node.E("label"), value = node.E("value"), group1 = node.E("group"), group2 = node.E("type"), cssclass = cssclass.ToString().Trim(), style = gtvalue != "" ? "display: none;" : "" });
        }
示例#8
0
        public HttpResponse ManualTimeEntry(string formatteddate, string location, string agent, string eventtype, int hours, int minutes)
        {
            try
            {
                Response.ContentType = "application/json";

                AgentEventClient aec = new AgentEventClient();

                DateTime eventdate = DateTime.ParseExact(formatteddate, "yyyyMMdd", CultureInfo.InvariantCulture);
                DateTime eventtime = new DateTime(eventdate.Year, eventdate.Month, eventdate.Day, hours, minutes, 0);

                AgentEvent manualevent = new AgentEvent();

                manualevent.PartitionKey = eventtime.ToString("yyyyMM");
                manualevent.RowKey       = ShortGuidGenerator.NewGuid();
                manualevent.EventTime    = eventtime;
                manualevent.Agent        = agent;
                manualevent.EventType    = eventtype;
                manualevent.Location     = location;

                aec.AddNewItem(manualevent);

                Response.Write("{\"result\": \"ok\"}");
                Response.End();
            }
            catch (Exception ex)
            {
                Response.ContentType = "application/json";
                Response.Write(DefaultErrorResponse(ex.Message));
                Response.End();
            }

            return(null);
        }
示例#9
0
        public SkillCowRequestSubmission()
        {
            DateTime t = EasternTimeConverter.Convert(DateTime.UtcNow);

            PartitionKey = t.ToString("yyyyMMdd");
            RowKey       = ShortGuidGenerator.NewGuid();
            Timestamp    = t;
        }
示例#10
0
        public UXEvent()
        {
            DateTime t = EasternTimeConverter.Convert(DateTime.UtcNow);

            PartitionKey = t.ToString("yyyyMMdd");
            RowKey       = ShortGuidGenerator.NewGuid();
            Timestamp    = t;
        }
 public PendingSchool()
 {
     PartitionKey = "pendingschool";
     Timestamp    = DateTime.UtcNow;
     RowKey       = ShortGuidGenerator.NewGuid();
     SubmitedOn   = EasternTimeConverter.Convert(DateTime.UtcNow);
     Pending      = true;
     Approved     = false;
     Duplicate    = false;
     Incorrect    = false;
 }
示例#12
0
        public AgentEvent(string agent, string eventtype, string location)
        {
            DateTime t = EasternTimeConverter.Convert(DateTime.UtcNow);

            PartitionKey = t.ToString("yyyyMM");
            RowKey       = ShortGuidGenerator.NewGuid();
            EventTime    = t;
            Agent        = agent;
            EventType    = eventtype;
            Location     = location;
        }
示例#13
0
        public bool SendDeferredProcessAsMessage(DeferredProcess process)
        {
            BrokeredMessage message = new BrokeredMessage("deferred");

            Type deferredType = process.GetType();

            message.Properties["Class"] = deferredType.FullName;
            message.Properties["ID"]    = ShortGuidGenerator.NewGuid();
            foreach (PropertyInfo pi in deferredType.GetProperties())
            {
                message.Properties[pi.Name] = pi.GetValue(process, null);
            }

            return(SendMessage(message));
        }
        private object processHidingGroup(XmlNode container)
        {
            XmlNode conditionsNode = container.SelectSingleNode("conditions");

            string targetCssClass = "hg_" + ShortGuidGenerator.NewGuid();

            List <object> rules = new List <object>();

            if (conditionsNode != null)
            {
                XmlNode ruleNode = conditionsNode.SelectSingleNode("rule");

                if (ruleNode != null)
                {
                    string hidingrule = ruleNode.InnerText;

                    string controlname = "";
                    string oper        = "";
                    string value       = "";

                    if (hidingrule.Contains("!="))
                    {
                        oper = "!=";
                        string[] tokens = hidingrule.Split(oper.ToCharArray());
                        controlname = tokens[0];
                        value       = tokens[2];
                    }
                    else
                    {
                        oper = "=";
                        string[] tokens = hidingrule.Split(oper.ToCharArray());
                        controlname = tokens[0];
                        value       = tokens[1];
                        oper        = "==";
                        if (value.Contains("||"))
                        {
                            oper = "in";
                        }
                    }

                    addControlEvent(controlname, oper, value, targetCssClass, "show", "hide");
                }
            }


            return(new { type = "hiding", label = container.A("label"), cssclass = targetCssClass, fields = ProcessInputsContainer(container).ToArray() });
        }
        public string SendDeferredProcessAsMessage(DeferredProcess process, string msgheader)
        {
            BrokeredMessage message = new BrokeredMessage(msgheader);

            string id           = ShortGuidGenerator.NewGuid();
            Type   deferredType = process.GetType();

            message.Properties["Class"] = deferredType.FullName;
            message.Properties["ID"]    = id;
            foreach (PropertyInfo pi in deferredType.GetProperties())
            {
                message.Properties[pi.Name] = pi.GetValue(process, null);
            }

            SendMessage(message);

            return(id);
        }
        public bool SaveJsonResource(string resourcetype, string containerName, string directoryPath, string resourceid, string json)
        {
            // Retrieve a reference to a container
            CloudBlobContainer container = blobClient.GetContainerReference(containerName);

            string[]           pathTokens = directoryPath.Split('/');
            CloudBlobDirectory dir        = container.GetDirectoryReference(pathTokens[0]);

            if (pathTokens.Length > 1)
            {
                for (var i = 1; i < pathTokens.Length; i++)
                {
                    dir = dir.GetSubdirectory(pathTokens[i]);
                }
            }

            // Create the container if it doesn't already exist
            container.CreateIfNotExist();
            container.SetPermissions(new BlobContainerPermissions {
                PublicAccess = BlobContainerPublicAccessType.Blob
            });

            try
            {
                CloudBlob jsblob = dir.GetBlobReference(resourceid + ".js");

                string guid = ShortGuidGenerator.NewGuid();

                if (resourcetype != null)
                {
                    jsblob.UploadText("var $" + guid + " = " + json + "; $" + resourcetype + "_ready($" + guid + ",'" + containerName + "', '" + resourceid + "', '" + directoryPath + "');");
                }
                else
                {
                    jsblob.UploadText("var $" + guid + " = " + json + "; $" + resourceid.Replace("-", "") + "_ready($" + guid + ",'" + containerName + "', '" + directoryPath + "');");
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public bool SaveJsonResource(string resourcetype, string containerName, string directoryPath, string resourceid, string json, bool ensurecontainerexists)
        {
            // Retrieve a reference to a container
            CloudBlobContainer container = blobClient.GetContainerReference(containerName);
            CloudBlobDirectory dir       = container.GetDirectoryReference(directoryPath);

            if (ensurecontainerexists)
            {
                // Create the container if it doesn't already exist
                container.CreateIfNotExist();
                container.SetPermissions(new BlobContainerPermissions {
                    PublicAccess = BlobContainerPublicAccessType.Blob
                });
            }

            try
            {
                CloudBlob jsblob   = dir.GetBlobReference(resourceid + ".js");
                CloudBlob jsonblob = dir.GetBlobReference(resourceid);

                string guid = ShortGuidGenerator.NewGuid();

                if (resourcetype != null)
                {
                    jsblob.UploadText("var $" + guid + " = " + json + "; $" + resourcetype + "_ready($" + guid + ",'" + containerName + "','" + resourceid + "');");
                }
                else
                {
                    jsblob.UploadText("var $" + guid + " = " + json + "; $" + resourceid.Replace("-", "") + "_ready($" + guid + ",'" + containerName + "');");
                }
                jsonblob.UploadText(json);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public ActionResult AddEntry(string d, string t, string from, string to)
        {
            try
            {
                if (!IsValidUser(tokens => tokens[0] == Request["username"].ToString()))
                {
                    return(null);
                }

                ThesaurusEntryClient c = new ThesaurusEntryClient();
                c.AddNewItem(new ThesaurusEntry {
                    PartitionKey = d, AddRemove = t, From = from, To = to, RowKey = ShortGuidGenerator.NewGuid()
                });
                NotifyApprovedItem(from, AuthTokens[2] + " added \"" + t + "\" relationship in " + d + " between \"" + from + "\" and \"" + to + "\"");

                if (d == "similars")
                {
                    var reverseitem = new ThesaurusEntry {
                        PartitionKey = d, AddRemove = t, From = to, To = from, RowKey = ShortGuidGenerator.NewGuid()
                    };
                    c.AddNewItem(reverseitem);
                    NotifyApprovedItem(to, AuthTokens[2] + " added \"" + t + "\" relationship in " + d + " between \"" + to + "\" and \"" + from + "\"");
                }

                Response.ContentType = "application/json";
                string retvalue = (new { result = "ok" }).ToJSON();
                Response.Write(retvalue);
                Response.End();
            }
            catch (Exception ex)
            {
                Response.ContentType = "application/json";
                Response.Write("{\"result\":\"error\", \"message\":\"" + ex.Message + "\"}");
                Response.End();
            }

            return(null);
        }
        private object createFieldGroup(string label, XmlNodeList nodes)
        {
            if (processedFieldGroups.Contains(label))
            {
                return(null);
            }

            string targetCssClass = "c" + ShortGuidGenerator.NewGuid();

            List <object> options = new List <object>();

            string hidingrule = "";
            bool   required   = false;
            string groupname  = targetCssClass;

            int cnt = 0;

            foreach (XmlNode node in nodes)
            {
                if (node.SelectSingleNode("fieldgroup") != null && node.SelectSingleNode("fieldgroup").A("label") != null && node.SelectSingleNode("fieldgroup").A("label") == label)
                {
                    if (cnt++ == 0)
                    {
                        XmlNode hidingNode = node.SelectSingleNode("hiding");
                        if (hidingNode != null)
                        {
                            XmlNode conditions = hidingNode.SelectSingleNode("conditions");

                            if (conditions != null)
                            {
                                XmlNode ruleNode = conditions.SelectSingleNode("rule");

                                if (ruleNode != null)
                                {
                                    hidingrule = ruleNode.InnerText;

                                    string controlname = "";
                                    string oper        = "";
                                    string value       = "";

                                    if (hidingrule.Contains("!="))
                                    {
                                        oper = "!=";
                                        string[] tokens = hidingrule.Split(oper.ToCharArray());
                                        controlname = tokens[0];
                                        value       = tokens[2];
                                    }
                                    else
                                    {
                                        oper = "=";
                                        string[] tokens = hidingrule.Split(oper.ToCharArray());
                                        controlname = tokens[0];
                                        value       = tokens[1];
                                        oper        = "==";
                                        if (value.Contains("||"))
                                        {
                                            oper = "in";
                                        }
                                    }

                                    addControlEvent(controlname, oper, value, targetCssClass, "show", "hide");
                                }
                            }
                        }
                    }

                    if (node.E("required") == "true")
                    {
                        required = true;
                    }
                    if (node.E("name") == "dobyear")
                    {
                        groupname = "dob";
                    }

                    if (node.A("type") == "dropdown")
                    {
                        options.Add(createInputDropDown(node));
                    }
                    else
                    {
                        options.Add(createInputGeneric(node));
                    }
                }
            }
            processedFieldGroups.Add(label);
            return(new { type = "fieldgroup", name = groupname, cssclass = targetCssClass, label = label, required = required, options = options.ToArray() });
        }
 public DirectSchoolClient()
 {
     PartitionKey = "same";
     RowKey       = ShortGuidGenerator.NewGuid();
     Timestamp    = DateTime.UtcNow;
 }
 public DirectSchoolClientLead()
 {
     RowKey    = ShortGuidGenerator.NewGuid();
     Timestamp = DateTime.UtcNow;
 }
 public CBNSchoolProgram()
 {
     //PartitionKey = SchoolId;
     RowKey = ShortGuidGenerator.NewGuid();
 }
 public CBNSchoolCampus()
 {
     //PartitionKey = "same"; //Set to SchoolId
     RowKey = ShortGuidGenerator.NewGuid();
 }
 public DirectEmployerClientCampusProgram()
 {
     PartitionKey = "same";
     RowKey       = ShortGuidGenerator.NewGuid();
     Timestamp    = DateTime.UtcNow;
 }
示例#25
0
 public CBNProfession()
 {
     PartitionKey = "same";
     RowKey       = ShortGuidGenerator.NewGuid();
 }
示例#26
0
 public JobPosting()
 {
     PartitionKey = "same";
     RowKey       = ShortGuidGenerator.NewGuid();
     Timestamp    = DateTime.UtcNow;
 }
        public ActionResult CreateEntry(ThesaurusEntry newitem)
        {
            try
            {
                if (!IsValidUser(tokens => tokens[0] == Request["username"].ToString()))
                {
                    return(RedirectToAction("Logon"));
                }

                newitem.Timestamp = DateTime.Now;
                if (ModelState.IsValid)
                {
                    ThesaurusEntryClient c = new ThesaurusEntryClient();
                    c.AddNewItem(newitem);
                    NotifyApprovedItem(newitem.From, AuthTokens[2] + " added \"" + newitem.AddRemove + "\" relationship in " + newitem.PartitionKey + " between \"" + newitem.From + "\" and \"" + newitem.To + "\"");

                    if (newitem.PartitionKey == "similars")
                    {
                        var reverseitem = new ThesaurusEntry {
                            AddedAs = "similar", PartitionKey = newitem.PartitionKey, AddRemove = newitem.AddRemove, From = newitem.To, To = newitem.From, RowKey = ShortGuidGenerator.NewGuid()
                        };
                        c.AddNewItem(reverseitem);
                        NotifyApprovedItem(newitem.To, AuthTokens[2] + " added \"" + newitem.AddRemove + "\" relationship in " + newitem.PartitionKey + " between \"" + newitem.To + "\" and \"" + newitem.From + "\"");
                    }
                }


                if (newitem.AddedAs == "predecessor")
                {
                    return(RedirectToAction("Index", new { p = newitem.To }));
                }
                else
                {
                    return(RedirectToAction("Index", new { p = newitem.From }));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("error", ex.Message);
                return(View(newitem));
            }
        }
        public ActionResult CreateEntry(string dictionary, string addremove, string from, string to)
        {
            if (!IsValidUser(tokens => tokens[0] == Request["username"].ToString()))
            {
                return(RedirectToAction("Logon"));
            }

            return(View(new ThesaurusEntry {
                PartitionKey = dictionary, AddRemove = addremove, From = from.Replace("^", "'"), To = to.Replace("^", "'"), RowKey = ShortGuidGenerator.NewGuid()
            }));
        }
        private void addControlEvent(string controlName, string oper, string value, string targetCssClass, string targetActionIfTrue, string targetActionIfFalse)
        {
            if (!controlEvents.ContainsKey(controlName))
            {
                controlEvents.Add(controlName, new List <object>());
            }

            List <object> list = controlEvents[controlName];

            if (oper == "in")
            {
                StringBuilder sbvalues = new StringBuilder();

                string[] tokens = value.Split(',');
                int      cnt    = 0;
                foreach (string token in tokens)
                {
                    if (cnt++ > 0)
                    {
                        sbvalues.Append(",");
                    }

                    sbvalues.Append("\"" + token + "\"");
                }
                list.Add(new { type = "hiding", oper = oper, value = sbvalues.ToString(), valueVariable = ShortGuidGenerator.NewGuid(), cssclass = targetCssClass, actionIfTrue = targetActionIfTrue, actionIfFalse = targetActionIfFalse });
            }
            else
            {
                if (oper == "=")
                {
                    oper = "==";
                }

                list.Add(new { type = "hiding", oper = oper, value = value, valueVariable = ShortGuidGenerator.NewGuid(), cssclass = targetCssClass, actionIfTrue = targetActionIfTrue, actionIfFalse = targetActionIfFalse });
            }
        }
示例#30
0
 public Agent()
 {
     PartitionKey = "same";
     RowKey       = ShortGuidGenerator.NewGuid();
 }