Пример #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["iid"] != "" && Request.QueryString["iid"] != null)
        {
            int inquiryid;
            Int32.TryParse(Request.QueryString["iid"], out inquiryid);

            using (InquiriesDataContext inquiryDb = new InquiriesDataContext())
            {
                inquiries myInquiry = inquiryDb.inquiries.Single(p => p.iid == inquiryid);

                //Check if user has access
                MembershipUser myUser = Membership.GetUser();
                if (myInquiry.uid == myUser.ProviderUserKey.ToString())
                {
                    if (myInquiry != null)
                    {
                        string selected = JeAcceptedList.SelectedValue;

                        InquiryManager.endInquiry(inquiryDb, inquiryid, selected, MessageContentTextBox.Text);
                        Response.Redirect("InquiryOverview.aspx");
                    }
                }
            }
        }
    }
Пример #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["iid"] != "")
        {
            InquiriesDataContext dbcontext = new InquiriesDataContext();

            int inquiryid;
            Int32.TryParse(Request.QueryString["iid"], out inquiryid);

            inquiries inq = dbcontext.inquiries.Single(p => p.iid == inquiryid);

            MembershipUser myUser = Membership.GetUser();
            if (inq.uid == myUser.ProviderUserKey.ToString())
            {
                List<string> selectedJes = new List<string>();
                foreach (ListItem item in JeCheckBoxList.Items)
                {
                    if (item.Selected == true)
                    {
                        selectedJes.Add(item.Value);
                    }
                }

                MessageManager.send(selectedJes.ToArray(), TitleTextBox.Text, MessageContentTextBox.Text);

                Response.Redirect("InquiryOverview.aspx");
            }
            else
            {
                StatusMessage.Text = "No access for this Inquiry";
                StatusMessage.Visible = true;
            }
        }
    }
Пример #3
0
    public static void cancelInquiry(InquiriesDataContext dbContext, long inquiryId)
    {
        inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId);

        myInquiry.status = 4;
        myInquiry.inquiry_end = DateTime.Now;

        dbContext.SubmitChanges();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        InquiriesDataContext dbcontext = new InquiriesDataContext();

        int inquiryid;
        Int32.TryParse(Request.QueryString["iid"], out inquiryid);

        inquiries inq = dbcontext.inquiries.Single(p => p.iid == inquiryid);

        MainTitle.Text = inq.title;
    }
Пример #5
0
    public static void sendToInquiryAudience(long inquiryId, string title, string message)
    {
        InquiriesDataContext dbcontext = new InquiriesDataContext();

        inquiries myInquiry = dbcontext.inquiries.Single(p => p.iid == inquiryId);

        //Send to all interested jes if interest phase
        if (myInquiry.status == 1)
        {
            var query = from likes in dbcontext.likes
                        where likes.iid == inquiryId
                        select likes;

            if (query.Count() != 0)
            {
                List<string> receivers = new List<string>();
                foreach (var like in query)
                {
                    receivers.Add(like.email);
                }

                MessageManager.send(receivers.ToArray(), title, message);
            }
        }
        //Send to all selected jes that submit proposals if proposal phase
        else if (myInquiry.status == 2) {
            var query = from likes in dbcontext.likes
                        where likes.iid == inquiryId
                        where likes.status > 1
                        select likes;

            if (query.Count() != 0)
            {
                List<string> receivers = new List<string>();
                foreach (var like in query)
                {
                    receivers.Add(like.email);
                }

                MessageManager.send(receivers.ToArray(), title, message);
            }
        }
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["iid"] != "" && Request.QueryString["iid"] != null)
        {
            int inquiryid;
            Int32.TryParse(Request.QueryString["iid"], out inquiryid);

            using (InquiriesDataContext inquiryDb = new InquiriesDataContext())
            {
                inquiries myInquiry = inquiryDb.inquiries.Single(p => p.iid == inquiryid);

                if (myInquiry != null)
                {
                    MainTitle.Text = myInquiry.title;
                    StatusLabel.Text = "In accepting the proposal of the junior enterprise you agree to our terms and conditions";
                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["iid"] != "")
        {
            InquiriesDataContext dbcontext = new InquiriesDataContext();

            int inquiryid;
            Int32.TryParse(Request.QueryString["iid"], out inquiryid);

            inquiries inq = dbcontext.inquiries.Single(p => p.iid == inquiryid);

            MembershipUser myUser = Membership.GetUser();
            if (inq.uid == myUser.ProviderUserKey.ToString())
            {

                List<string> selectedJes = new List<string>();
                foreach (ListItem item in JeCheckBoxList.Items)
                {
                    if (item.Selected == true)
                    {
                        selectedJes.Add(item.Value);
                    }
                }

                if (selectedJes.Count != 0)
                {
                    string[] jeids = selectedJes.ToArray();

                    DateTime prop_start = DateTime.ParseExact(ProposalPhaseStartTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    DateTime prop_end = DateTime.ParseExact(ProposalPhaseEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);

                    InquiryManager.startProposalPhase(inq.iid, jeids, MessageContentTextBox.Text, prop_start, prop_end);

                    Response.Redirect("InquiryOverview.aspx");
                }
                else
                {
                    StatusMessage.Text = "Please select at least one Junior enterprise";
                    StatusMessage.Visible = true;
                }
            }
        }
    }
Пример #8
0
    //Starts proposal phase, sets status and sends out invitations
    public static void startProposalPhase(long inquiryId, string[] jeids, string message, DateTime propstart, DateTime propend)
    {
        InquiriesDataContext dbContext = new InquiriesDataContext();
        inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId);

        myInquiry.proposal_start = propstart;
        myInquiry.proposal_end = propend;
        myInquiry.status = 2;

        dbContext.SubmitChanges();

        List<string> receivers = new List<string>();
        foreach (var single in jeids)
        {
            likes like = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == single);
            like.status = 2;
            receivers.Add(like.email);
        }
        dbContext.SubmitChanges();

        //Send Web Service request send.proposalrequest
        //Load user name from uid
        Guid userKey = new Guid(myInquiry.uid);
        MembershipUser user = Membership.GetUser(userKey);

        //Load profile from username
        ProfileCommon pObj = new ProfileCommon().GetProfile(user.UserName);

        Dictionary<string, dynamic> args = new Dictionary<string, dynamic>();
        args.Add("method", "send.proposalrequest");
        args.Add("companyname", pObj.CompanyName);
        args.Add("iid", myInquiry.iid);
        args.Add("receivers", jeids);
        args.Add("title", "Proposal submit invitation");
        args.Add("message", message);

        WebRequestHandler.load(args);

        //Send introductory message to junior enterprises
        MessageManager.send(receivers.ToArray(), "Invitation to submit proposal for " + myInquiry.title, message);
    }
Пример #9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int inquiryid;
        Int32.TryParse(Request.QueryString["iid"], out inquiryid);

        InquiriesDataContext dbContext = new InquiriesDataContext();
        inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryid);

        MembershipUser myUser = Membership.GetUser();
        if (myInquiry.uid == myUser.ProviderUserKey.ToString())
        {
            InquiryManager.cancelInquiry(dbContext, inquiryid);

            //If no likes were present
            if (dbContext.likes.Count(p => p.iid == inquiryid) <= 0)
            {
                Response.Redirect("InquiryOverview.aspx");
            }
            //If inquiry in proposal phase and no proposals present
            else if (dbContext.likes.Count(p => p.iid == inquiryid && p.status == 3) == 0 && myInquiry.status == 2)
            {
                Response.Redirect("InquiryOverview.aspx");
            }
            //If likes were present send the jes a cancel message
            else if (myInquiry.status == 1)
            {
                Response.Redirect("SendCancelMessage.aspx?iid=" + inquiryid);
            }

            Response.Redirect("InquiryOverview.aspx");
        }
        else
        {
            StatusLabel.Text = "You don't have access to this inquiry";
            StatusLabel.Visible = true;
        }
    }
Пример #10
0
    public static bool addLike(long inquiryId, string jeid, string name, string email)
    {
        InquiriesDataContext dbContext = new InquiriesDataContext();

        //Check if like already present
        likes myLike = null;
        try
        {
            myLike = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == jeid);
        }
        catch (Exception ex)
        {
            //Sequence is empty
        }

        if (myLike == null)
        {
            likes newLike = new likes();
            newLike.created = DateTime.Now;
            newLike.iid = inquiryId;
            newLike.jeid = jeid;
            newLike.name = name;
            newLike.email = email;
            //Status 1 == normal active, Status 2 == invited to proposal, Status 3 == proposal submitted, Status 4 == propsal accepted
            newLike.status = 1;

            dbContext.likes.InsertOnSubmit(newLike);

            dbContext.SubmitChanges();
            return true;
        }
        else
        {
            return false;
        }
    }
Пример #11
0
    public static void endInquiry(InquiriesDataContext dbContext, long inquiryId, string jeId, string endMessage)
    {
        inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId);

        if (myInquiry != null) {
            var query = from likes in dbContext.likes
                        where likes.iid == inquiryId
                        where likes.status == 3
                        select likes;

            List<string> audience = new List<string>();
            if (query.Count() != 0)
            {
                foreach (var like in query)
                {
                    if (like.jeid != jeId)
                    {
                        audience.Add(like.email);
                    }
                    else
                    {
                        like.status = 4;
                    }
                }
            }

            string message = "Your proposal was not accepted - Please try again at the next inquiry";
            if (endMessage != "")
            {
                message = endMessage;
            }

            myInquiry.inquiry_end = DateTime.Now;
            myInquiry.status = 3;

            dbContext.SubmitChanges();

            MessageManager.send(audience.ToArray(), "Your proposal for " + myInquiry.title + " was not accepted", message);
        }
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //If profile has been validated
        if (Profile.Status > 1)
        {
            InquiriesDataContext dbcontext = new InquiriesDataContext();

            MembershipUser myUser = Membership.GetUser();

            //Populate acive inquiry table
            var query = from inquiries in dbcontext.inquiries
                        where inquiries.uid == myUser.ProviderUserKey.ToString()
                        where inquiries.status > 0
                        where inquiries.status < 3
                        select inquiries;

            if (query.Count() != 0)
            {
                string[] headers = { "Title", "Interest", "Proposals", "" };
                TableHeaderRow header = new TableHeaderRow();
                header.TableSection = TableRowSection.TableHeader;
                foreach (var str in headers)
                {
                    TableHeaderCell thead = new TableHeaderCell();
                    thead.Text = str;
                    header.Cells.Add(thead);
                }
                InquiryTable.Rows.Add(header);

                foreach (var inq in query)
                {
                    TableRow tRow = new TableRow();

                    //Create main link cell
                    TableCell tCell = new TableCell();
                    HyperLink mainlink = new HyperLink();
                    mainlink.NavigateUrl = "~/Account/ViewInquiry.aspx?iid=" + inq.iid;
                    mainlink.Text = inq.title;

                    tCell.Controls.Add(mainlink);
                    tRow.Cells.Add(tCell);

                    //Create interest cell
                    TableCell tCell2 = new TableCell();

                    int likesum = InquiryManager.getLikesCount(dbcontext, inq.iid);
                    tCell2.Text = likesum + " Junior enterprises";
                    tRow.Cells.Add(tCell2);

                    //Create proposal cell
                    TableCell tCell3 = new TableCell();

                    Dictionary<string, string> link = InquiryManager.getProposalStatusMessage(dbcontext, inq.iid);

                    if (link.ContainsKey("url"))
                    {
                        HyperLink proposalLink = new HyperLink();
                        proposalLink.NavigateUrl = link["url"];
                        proposalLink.Text = link["text"];
                        tCell3.Controls.Add(proposalLink);
                    }
                    else
                    {
                        tCell3.Text = link["text"];
                    }

                    tRow.Cells.Add(tCell3);

                    //Create controls cell
                    TableCell tCell4 = new TableCell();
                    tCell4.CssClass = "control-cell";

                    if (likesum > 0)
                    {
                        HyperLink sendLink = new HyperLink();
                        sendLink.NavigateUrl = "~/Account/SendMessage.aspx?iid=" + inq.iid;
                        sendLink.Text = "Send message to inquiry audience";
                        sendLink.CssClass = "send-link";
                        tCell4.Controls.Add(sendLink);
                    }

                    HyperLink editLink = new HyperLink();
                    editLink.NavigateUrl = "~/Account/EditInquiry.aspx?iid=" + inq.iid;
                    editLink.Text = "Edit";
                    editLink.CssClass = "edit-link";
                    tCell4.Controls.Add(editLink);

                    HyperLink cancelLink = new HyperLink();
                    cancelLink.NavigateUrl = "~/Account/CancelInquiry.aspx?iid=" + inq.iid;
                    cancelLink.Text = "Cancel";
                    cancelLink.CssClass = "cancel-link";
                    tCell4.Controls.Add(cancelLink);

                    tRow.Cells.Add(tCell4);

                    InquiryTable.Rows.Add(tRow);
                }
            }
            else
            {
                InquiryEmptyLabel.Text = "No active inquiries";
            }

            //Populate closed inquiry table
            query = from inquiries in dbcontext.inquiries
                    where inquiries.uid == myUser.ProviderUserKey.ToString()
                    where inquiries.status > 2
                    select inquiries;

            if (query.Count() != 0)
            {
                string[] headers = { "Title", "Ended on", "Proposals", "Accepted Proposal", "" };
                TableHeaderRow header = new TableHeaderRow();
                header.TableSection = TableRowSection.TableHeader;
                foreach (var str in headers)
                {
                    TableHeaderCell thead = new TableHeaderCell();
                    thead.Text = str;
                    header.Cells.Add(thead);
                }
                ClosedInquiryTable.Rows.Add(header);

                foreach (var inq in query)
                {
                    TableRow tRow = new TableRow();

                    TableCell tCell = new TableCell();
                    HyperLink mainlink = new HyperLink();
                    mainlink.NavigateUrl = "~/Account/ViewInquiry.aspx?iid=" + inq.iid;
                    mainlink.Text = inq.title;
                    tCell.Controls.Add(mainlink);
                    tRow.Cells.Add(tCell);

                    TableCell tCell2 = new TableCell();
                    if (inq.inquiry_end != null)
                    {
                        tCell2.Text = inq.inquiry_end.Value.ToString("yyyy-MM-dd");
                    }
                    tRow.Cells.Add(tCell2);

                    TableCell tCell3 = new TableCell();

                    Dictionary<string, string> link = InquiryManager.getProposalStatusMessage(dbcontext, inq.iid);
                    if (link.ContainsKey("url"))
                    {
                        HyperLink proposalLink = new HyperLink();
                        proposalLink.NavigateUrl = link["url"];
                        proposalLink.Text = link["text"];
                        tCell3.Controls.Add(proposalLink);
                    }
                    else
                    {
                        tCell3.Text = link["text"];
                    }

                    tRow.Cells.Add(tCell3);

                    TableCell tCell4 = new TableCell();
                    if (inq.status == 3)
                    {
                        string propname = InquiryManager.getAcceptedProposalFileName(inq.iid);
                        if (propname != "")
                        {
                            HyperLink proplink = new HyperLink();
                            proplink.Text = "View accepted proposal";
                            proplink.NavigateUrl = propname;
                            tCell4.Controls.Add(proplink);
                        }
                        else
                        {
                            tCell4.Text = "Proposal accepted";
                        }
                    }
                    else
                    {
                        tCell4.Text = "No proposal accepted";
                    }
                    
                    tRow.Cells.Add(tCell4);

                    //Build controls
                    TableCell tCell5 = new TableCell();
                    tRow.Cells.Add(tCell5);

                    ClosedInquiryTable.Rows.Add(tRow);
                }
            }
            else
            {
                ClosedInquiryEmptyLabel.Text = "No inquiries completed";
            }
        }
        else if (Profile.Status == 0)
        {
            HyperLink2.Visible = Label1.Visible = Label2.Visible = false;
            StatusMessage.Text = "Please submit your profile for validation - You can't create inquiries until your profile is validated.";
            StatusMessage.CssClass = "messages";
            ProfileCreationLink.Visible = true;
        }
        else
        {
            HyperLink2.Visible = Label1.Visible = Label2.Visible = false;
            StatusMessage.Text = "You can't create inquiries until your profile is validated.";
            StatusMessage.CssClass = "messages";
        }
    }
Пример #13
0
    public static bool addProposal(long inquiryId, string jeid, string url)
    {
        InquiriesDataContext dbContext = new InquiriesDataContext();

        //Update existing like status
        likes myLike = null;
        try
        {
            myLike = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == jeid);
        }
        catch (Exception ex)
        {
            //No inquiry there
        }

        if (myLike != null)
        {
            myLike.status = 3;

            files newFile = new files();
            newFile.created = DateTime.Now;
            newFile.external_url = url;

            newFile.likes.Add(myLike);

            dbContext.SubmitChanges();

            return true;
        }
        else
        {
            return false;
        }

    }
Пример #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String jeidstring = Request.QueryString["jeid"];

        if (jeidstring != "" && jeidstring != null)
        {
            InquiriesDataContext dbcontext = new InquiriesDataContext();

            //likes myLike = dbcontext.likes.Single(p => p.jeid == jeidstring);
			likes myLike = null;
			
			var query = from likes in dbcontext.likes
                        where likes.jeid == jeidstring
                        select likes;
			
			if (query.Count() != 0)
            {
			    foreach (var lik in query) {
				  myLike = lik;
				  break;
				}
			}

            if (myLike != null)
            {
                //Get new Je Profile data
                Dictionary<string, dynamic> args = new Dictionary<string, dynamic>();
                args.Add("method", "load.jeprofile");
                args.Add("jeid", jeidstring);

                MainTitleLabel.Text = PageTitleLabel.Text = myLike.name;

                ContactEmailLink.Text = myLike.email;
                ContactEmailLink.NavigateUrl = "mailto:" + myLike.email;

                string result = WebRequestHandler.load(args);

                //Get the results
                JObject resultObject = JObject.Parse(result);

                JToken results;
                if (resultObject.TryGetValue("results", out results))
                {
                    IList<JToken> resultList = results.Children().ToList();

                    JuniorEnterprise je = null;

                    foreach (JToken item in resultList)
                    {
                        je = JsonConvert.DeserializeObject<JuniorEnterprise>(item.ToString());
                    }

                    //If we got something from the Web Request
                    if (je != null)
                    {
                        LogoImage.Width = 160;
                        LogoImage.ImageUrl = je.logo_url;

                        DescriptionTextLiteral.Text = je.description;

                        StreetLabel.Text = je.address.street;
                        PostalCodeLabel.Text = je.address.postal_code;
                        CityLabel.Text = je.address.city;
                        StreetLabel.Text = je.address.street;
                        CountryLabel.Text = je.address.country;
                    }
                }
            }
        }
    }
Пример #15
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid && Profile.Status > 1)
        {
            //If File has been uploaded
            string newfilepath = "";
            bool fileOK = false;
            string path = Server.MapPath("~/Files/");
            if (FileUpload1.HasFile)
            {
                string filePath = FileUpload1.FileName;
                if (filePath.EndsWith(".doc") || filePath.EndsWith(".docx") || filePath.EndsWith(".pdf"))
                {
                    double fileSize = FileUpload1.FileBytes.Length;
                    double fileSizeInMB = fileSize / (1024 * 1024);
                    if (fileSizeInMB < 20)
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK)
            {
                try
                {
                    newfilepath = path + FileUpload1.FileName;
                    FileUpload1.PostedFile.SaveAs(newfilepath);
                    FileUploadedLabel.Text = FileUpload1.FileName;
                }
                catch (Exception ex)
                {
                }
            }

            using (InquiriesDataContext inquiryDb = new InquiriesDataContext())
            {
                //If existing inquiry ist updated
                if (Request.QueryString["iid"] != "" && Request.QueryString["iid"] != null)
                {
                    int inquiryid;
                    Int32.TryParse(Request.QueryString["iid"], out inquiryid);

                    inquiries newInquiry = inquiryDb.inquiries.Single(p => p.iid == inquiryid);

                    //Check if user has access
                    MembershipUser myUser = Membership.GetUser();
                    if (newInquiry.uid == myUser.ProviderUserKey.ToString())
                    {
                        newInquiry.title = TitleTextBox.Text;
                        newInquiry.description = DescriptionTextBox.Text;
                        newInquiry.interest_start = DateTime.ParseExact(InterestPhaseTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                        newInquiry.interest_end = DateTime.ParseExact(InterestPhaseEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                        newInquiry.updated = DateTime.Now;

                        //New file uploaded
                        if (newfilepath != "")
                        {
						  files newfile = new files();
                          newfile.filename = FileUpload1.FileName;
                          newfile.filepath = newfilepath;
                          newfile.filesize = FileUpload1.FileBytes.Length;
                          newfile.created = DateTime.Now;

                          newfile.inquiries.Add(newInquiry);
                        }
                    }

                    //If already in proposal phase let users change proposal dates
                    if (newInquiry.status == 2)
                    {
                        newInquiry.proposal_start = DateTime.ParseExact(ProposalStartTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                        newInquiry.proposal_end = DateTime.ParseExact(ProposalEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    }

                    inquiryDb.SubmitChanges();

                    //Send update webservice request
                    Dictionary<string, dynamic> args = new Dictionary<string, dynamic>();
                    args.Add("method", "update.inquiry");
                    args.Add("iid", newInquiry.iid);
                    args.Add("uid", newInquiry.uid);
                    args.Add("companyname", Profile.CompanyName);
                    args.Add("title", newInquiry.title);
                    args.Add("description", newInquiry.description);
					if(newInquiry.files != null) {
                      args.Add("filepath", newInquiry.files.filepath);
					}

                    //Convert datetime to unix timestamp
                    DateTime unixStart = new DateTime(1970, 1, 1);

                    if (newInquiry.interest_start != null)
                    {
                        TimeSpan span = new TimeSpan(newInquiry.interest_start.Value.Ticks - unixStart.Ticks);
                        args.Add("interest_start", Convert.ToInt32(span.TotalSeconds));
                    }
                    else
                    {
                        args.Add("interest_start", "");
                    }

                    if (newInquiry.interest_end != null)
                    {
                        TimeSpan span2 = new TimeSpan(newInquiry.interest_end.Value.Ticks - unixStart.Ticks);
                        args.Add("interest_end", Convert.ToInt32(span2.TotalSeconds));
                    }
                    else
                    {
                        args.Add("interest_end", "");
                    }

                    if (newInquiry.proposal_start != null)
                    {
                        TimeSpan span3 = new TimeSpan(newInquiry.proposal_start.Value.Ticks - unixStart.Ticks);
                        args.Add("proposal_start", Convert.ToInt32(span3.TotalSeconds));
                    }
                    else
                    {
                        args.Add("proposal_start", "");
                    }

                    if (newInquiry.proposal_end != null)
                    {
                        TimeSpan span4 = new TimeSpan(newInquiry.proposal_end.Value.Ticks - unixStart.Ticks);
                        args.Add("proposal_end", Convert.ToInt32(span4.TotalSeconds));
                    }
                    else
                    {
                        args.Add("proposal_end", "");
                    }

                    if (newInquiry.inquiry_end != null)
                    {
                        TimeSpan span5 = new TimeSpan(newInquiry.inquiry_end.Value.Ticks - unixStart.Ticks);
                        args.Add("inqiry_end", Convert.ToInt32(span5.TotalSeconds));
                    }
                    else
                    {
                        args.Add("inquiry_end", "");
                    }

                    WebRequestHandler.load(args);

                    StatusLabel.Visible = true;
                    StatusLabel.Text = "Inquiry updated";
                }
                //If new inquiry is created
                else
                {
                    inquiries myInquiry = new inquiries();
                    myInquiry.title = TitleTextBox.Text;
                    myInquiry.description = DescriptionTextBox.Text;

                    DateTime intereststart;
                    myInquiry.interest_start = intereststart = DateTime.ParseExact(InterestPhaseTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);

                    DateTime interestend;
                    myInquiry.interest_end = interestend = DateTime.ParseExact(InterestPhaseEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture);

                    myInquiry.created = myInquiry.updated = DateTime.Today;

                    MembershipUser myUser = Membership.GetUser();
                    myInquiry.uid = myUser.ProviderUserKey.ToString();
                    myInquiry.status = 1;

                    //New file uploaded
                    if (newfilepath != "")
                    {
                        files newfile = new files();
                        newfile.filename = FileUpload1.FileName;
                        newfile.filepath = newfilepath;
                        newfile.filesize = FileUpload1.FileBytes.Length;
                        newfile.created = DateTime.Now;

                        newfile.inquiries.Add(myInquiry);
                    }

                    inquiryDb.inquiries.InsertOnSubmit(myInquiry);
                    inquiryDb.SubmitChanges();

                    Dictionary<string, dynamic> args = new Dictionary<string, dynamic>();
                    args.Add("method", "send.inquiry");
                    args.Add("iid", myInquiry.iid);
                    args.Add("uid", myInquiry.uid);
                    args.Add("companyname", Profile.CompanyName);
                    args.Add("title", myInquiry.title);
                    args.Add("description", myInquiry.description);
                    args.Add("status", myInquiry.status);
                    if (newfilepath != "")
                    {
                        args.Add("filepath", newfilepath);
                    }

                    //Convert datetime to unix timestamp
                    DateTime unixStart = new DateTime(1970, 1, 1);

                    TimeSpan span = new TimeSpan(intereststart.Ticks - unixStart.Ticks);
                    args.Add("interest_start", Convert.ToInt32(span.TotalSeconds));

                    TimeSpan span2 = new TimeSpan(interestend.Ticks - unixStart.Ticks);
                    args.Add("interest_end", Convert.ToInt32(span2.TotalSeconds));

                    WebRequestHandler.load(args);
                    Response.Redirect("InquiryOverview.aspx");
                }

                //Server.Transfer("InquiryOverview.aspx", false);
            }
        }
    }
Пример #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MainTitle.Text = "Create new inquiry";
        //If Request iis is not empty load settings
        if (Profile.Status > 1)
        {
            if (Request.QueryString["iid"] != "" && Request.QueryString["iid"] != null)
            {
                //@Todo Add check if user has access to the inquiry

                InquiriesDataContext dbcontext = new InquiriesDataContext();

                int inquiryid;
                Int32.TryParse(Request.QueryString["iid"], out inquiryid);

                inquiries inq = dbcontext.inquiries.Single(p => p.iid == inquiryid);

                MainTitle.Text = "Edit inquiry " + inq.title;
                Button1.Text = "Save changes";

                if (TitleTextBox.Text == "")
                {
                    TitleTextBox.Text = inq.title;
                }
                if (DescriptionTextBox.Text == "")
                {
                    DescriptionTextBox.Text = inq.description;
                }
                if (InterestPhaseTextBox.Text == "")
                {
                    InterestPhaseTextBox.Text = inq.interest_start.Value.ToString("yyyy-MM-dd");
                }
                if (InterestPhaseEndTextBox.Text == "")
                {
                    InterestPhaseEndTextBox.Text = inq.interest_end.Value.ToString("yyyy-MM-dd");
                }
				
				if (inq.files != null)
                {
                  FileUploadedLink.Text = "Download uploaded file";
                  FileUploadedLink.NavigateUrl = ResolveUrl("~/Files/") + inq.files.filename;
				  FileUploadedLabel.Visible = false;
                }

                //Populate proposal start date
                if (inq.status == 2)
                {
                    ProposalStartPanel.Visible = true;
                    ProposalEndPanel.Visible = true;
                    if (ProposalStartTextBox.Text == "")
                    {
                        ProposalStartTextBox.Text = inq.proposal_start.Value.ToString("yyyy-MM-dd");
                    }
                    if (ProposalEndTextBox.Text == "")
                    {
                        ProposalEndTextBox.Text = inq.proposal_end.Value.ToString("yyyy-MM-dd");
                    }
                }
            }
        }
        else
        {
            StatusLabel.Visible = true;
            StatusLabel.CssClass = "messages notice";
            StatusLabel.Text = "You can't create projects yet. Your account has to be validated by an administrator.";
        }
    }
Пример #17
0
 public static int getLikesCount(InquiriesDataContext dbContext, long inquiryId)
 {
     return dbContext.likes.Count(p => p.iid == inquiryId);
 }
Пример #18
0
    public static string getAcceptedProposalFileName(long iid)
    {
        InquiriesDataContext dbcontext = new InquiriesDataContext();

        likes acceptedLike = dbcontext.likes.Single(p => p.iid == iid && p.status == 4);
        return acceptedLike.files.external_url;
    }
Пример #19
0
    //Outputs current status string for proposals
    public static Dictionary<string, string> getProposalStatusMessage(InquiriesDataContext dbContext, long inquiryId)
    {
        inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId);

        Dictionary<string,string> output = new Dictionary<string,string>();

        switch (myInquiry.status)
        {
            //Inquiry hasn't started yet
            case 0:
                output.Add("text", "Inquiry hasn't started yet");
                break;

            //Inquiry is in introductory phase - Likes may happen
            case 1:
                DateTime interestEnd;

                //Prevent errors if date isn't specified
                if (myInquiry.interest_end != null)
                {
                    interestEnd = myInquiry.interest_end.Value;
                }
                else
                {
                    interestEnd = DateTime.Now;
                }

                //Introductory phase running
                if (DateTime.Compare(DateTime.Now, interestEnd) <= 0) { 
                    output.Add("text", "End of introductory phase: " + interestEnd.ToString("yyyy-MM-dd"));
                }
                //Introductory phase over - notify user to start proposal phase
                else {
                    //Check if likes are present
                    var query = from likes in dbContext.likes
                                where likes.iid == inquiryId
                                select likes;

                    if (query.Count() != 0)
                    {
                        output.Add("url", "StartProposalPhase.aspx?iid=" + inquiryId);
                        output.Add("text", "Start Proposal Phase");
                    }
                    else
                    {
                        output.Add("url", "CancelInquiry.aspx?iid=" + inquiryId);
                        output.Add("text", "No junior enterprise liked your project - Cancel inquiry");
                    }
                }
                break;

            //Inquiry is in proposal phase - Proposals may be submitted
            case 2:
                DateTime proposalEnd;

                //Prevent errors if date isn't specified
                if (myInquiry.proposal_end != null)
                {
                    proposalEnd = myInquiry.proposal_end.Value;
                }
                else
                {
                    proposalEnd = DateTime.Now;
                }

                //Proposal phase running
                if (DateTime.Compare(DateTime.Now, proposalEnd) <= 0)
                { 
                    output.Add("text", "End of proposal phase: " + proposalEnd.ToString("yyyy-MM-dd"));
                }
                //Proposal phase over - let user select proposal / end inquiry
                else {
                    //Check if likes are present
                    var query = from likes in dbContext.likes
                                where likes.iid == inquiryId
                                where likes.status == 3
                                select likes;

                    if (query.Count() != 0)
                    {
                        output.Add("url", "EndInquiry.aspx?iid=" + inquiryId);
                        output.Add("text", "Accept proposal and end inquiry");
                    }
                    else
                    {
                        output.Add("url", "CancelInquiry.aspx?iid=" + inquiryId);
                        output.Add("text", "No junior enterprise submitted a proposal - Cancel inquiry");
                    }
                }
                break;

            //Inquiry is over - Proposal accepted
            case 3:
                output.Add("text", "Inquiry ended - Proposal accepted");
                break;

            //Inquiry is over - Cancelled
            case 4:
                output.Add("text", "Inquiry cancelled");
                break;
        }
        return output;
    }
Пример #20
0
    public static bool invalidateJeprofile(string jeid)
    {
        InquiriesDataContext dbcontext = new InquiriesDataContext();

        var query = from likes in dbcontext.likes
                    where likes.jeid == jeid
                    where likes.inquiries.status > 2
                    select likes;

        if (query.Count() != 0)
        {
            //Get new Je Profile data
            Dictionary<string, dynamic> args = new Dictionary<string,dynamic>();
            args.Add("method", "load.jeprofile");
            args.Add("jeid", jeid);

            String result = WebRequestHandler.load(args);

            //Get the results
            JObject resultObject = JObject.Parse(result);

            JToken results;
            if (resultObject.TryGetValue("results", out results))
            {
                IList<JToken> resultList = results.Children().ToList();

                JuniorEnterprise je = null;

                foreach (JToken item in resultList)
                {
                    je = JsonConvert.DeserializeObject<JuniorEnterprise>(item.ToString());
                }

                //If we got something from the Web Request
                if (je != null)
                {
                    foreach (var item in query)
                    {
                        item.email = je.email;
                        item.name = je.name;
                    }

                    dbcontext.SubmitChanges();

                    return true;
                }
            }
        }

        return false;
    }