コード例 #1
0
ファイル: Vendor.cs プロジェクト: WakeDown/UnitApis
 public static bool Delete(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/Vendor/Close?id={1}", OdataServiceUri, id));
     string json = String.Empty;
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #2
0
ファイル: DbModel.cs プロジェクト: WakeDown/UnitApis
        protected static bool PostJson(Uri uri, string json, out ResponseMessage responseMessage)
        {
            var request = (HttpWebRequest)WebRequest.Create(uri);
            CredentialCache cc = new CredentialCache();
            cc.Add(uri, "NTLM", CredentialCache.DefaultNetworkCredentials);
            request.Credentials = cc;
            //request.Headers.Add("Authorization", AuthorizationHeaderValue);
            request.ContentType = "text/json";
            request.Method = "POST";

            using (var streamWriter = new StreamWriter(request.GetRequestStream()))
            {
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var response = (HttpWebResponse)request.GetResponse();
                using (var streamReader = new StreamReader(response.GetResponseStream()))
                {
                    string responseContent = streamReader.ReadToEnd();
                    responseMessage = JsonConvert.DeserializeObject<ResponseMessage>(responseContent);
                }

            return response.StatusCode == HttpStatusCode.Created;
        }
コード例 #3
0
ファイル: Vendor.cs プロジェクト: WakeDown/UnitApis
 public bool Save(out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/Vendor/Save", OdataServiceUri));
     string json = JsonConvert.SerializeObject(this);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #4
0
 public static bool Close(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHolidayTransferDay/Close?id={1}",OdataServiceUri));
     string json = string.Empty;
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #5
0
ファイル: DocMeetLink.cs プロジェクト: WakeDown/UnitApis
 public static bool Delete(int idDocument, int? idDepartment, int? idPosition, int? idEmployee, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/DocMeetLink/Close?idDocument={1}&idDepartment={2}&idPosition={3}&idEmployee={4}", OdataServiceUri, idDocument, idDepartment, idPosition, idEmployee));
     string json = String.Empty;//JsonConvert.SerializeObject(new DocMeetLink(){IdDocument = idDocument, IdDepartment = idDepartment, IdPosition = idPosition, IdEmployee = idEmployee});
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #6
0
ファイル: OrgStateImage.cs プロジェクト: WakeDown/UnitApis
 //private void FillSelf(OrgStateImage model)
 //{
 //    Id = model.Id;
 //    IdOrganization = model.IdOrganization;
 //    Image = model.Image;
 //}
 //public bool Save(out ResponseMessage responseMessage)
 //{
 //    Uri uri = new Uri(String.Format("{0}/Department/Save", OdataServiceUri));
 //    string json = JsonConvert.SerializeObject(this);
 //    bool result = PostJson(uri, json, out responseMessage);
 //    return result;
 //}
 //public static IEnumerable<Department> GetList()
 //{
 //    Uri uri = new Uri(String.Format("{0}/Department/GetList", OdataServiceUri));
 //    string jsonString = GetJson(uri);
 //    var deps = JsonConvert.DeserializeObject<IEnumerable<Department>>(jsonString);
 //    return deps;
 //}
 public static bool Delete(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/Organization/CloseStateImage?id={1}", OdataServiceUri, id));
     string json = String.Empty;//String.Format("{{\"id\":{0}}}",id);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #7
0
 //Добавить день
 public bool Save(out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{}/RestHolidayTransferDay/Save",OdataServiceUri));
     string json = JsonConvert.SerializeObject(this);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: aleks19921015/Stuff
        public static void VendorStateDelivery(VendorStateDeliveryType type)
        {
            string stuffUri = ConfigurationManager.AppSettings["stuffUrl"];
            var vendorStateList = VendorState.GetDeliverList((byte)type);
            var addressList = type == VendorStateDeliveryType.Expired ?
                VendorState.GetExpiredMailAddressList() : Employee.GetFullRecipientList();
            var mailList = (from s in addressList where !String.IsNullOrEmpty(s) select new MailAddress(s)).ToArray();
            var body = new StringBuilder("Добрый день.<br/>");
            if (vendorStateList.Any())
            {
                switch (type)
                {
                    case VendorStateDeliveryType.Newbie:
                        NewVendorStateDelivery(vendorStateList, stuffUri, body, mailList);
                        break;
                    case VendorStateDeliveryType.Update:
                        UpdVendorStateDelivery(vendorStateList, stuffUri, body, mailList);
                        break;
                    case VendorStateDeliveryType.Expired:
                        ExpiredVendorStateDelivery(vendorStateList, stuffUri, body, mailList);
                        break;
                }

                var responseMessage = new ResponseMessage();
                var complete = VendorState.SetDeliverySent(out responseMessage, (byte)type, vendorStateList.ToArray());
            }
        }
コード例 #9
0
ファイル: VendorState.cs プロジェクト: aleks19921015/Stuff
 public static bool SetDeliverySent(out ResponseMessage responseMessage, byte type, params VendorState[] vendorStates)
 {
     Uri uri = new Uri(String.Format("{0}/VendorState/SetDeliverySent?deliveryType={1}", OdataServiceUri,type));
     string json = JsonConvert.SerializeObject(vendorStates);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #10
0
        public bool SaveVendorState(VendorState vnd, out ResponseMessage responseMessage)
        {
            if (Request.Files.Count > 0 && Request.Files[0] != null && Request.Files[0].ContentLength > 0)
            {
                var file = Request.Files[0];
                if (file.ContentLength > 5242880)
                {
                    responseMessage = new ResponseMessage();
                    responseMessage.ErrorMessage = "Нельзя загрузить файл размером более 5 мегабайт. Файл не был загружен.";
                    return false;
                }

                string ext = Path.GetExtension(file.FileName).ToLower();

                if (ext != ".jpeg" && ext != ".jpg") throw new Exception("Формат фотографии должен быть jpeg");

                byte[] picture = null;
                using (var br = new BinaryReader(file.InputStream))
                {
                    picture = br.ReadBytes(file.ContentLength);
                }
                vnd.Picture = picture;
            }
            //var chkCreateAdUser = Request.Form["chkCreateAdUser"];
            //bool createAdUser = chkCreateAdUser != "false";.
            if (vnd.EndDate.Equals(new DateTime()))
                vnd.EndDate=new DateTime(3333,3,3);
            bool complete = vnd.Save(out responseMessage);
            return complete;
        }
コード例 #11
0
ファイル: RestHoliday.cs プロジェクト: aleks19921015/Stuff
 public static bool SetCanEdit(int[] idArray, bool canEdit, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHoliday/CanEdit?canEdit={1}",OdataServiceUri,canEdit));
     var json = JsonConvert.SerializeObject(idArray);
     return PostJson(uri, json, out responseMessage);
 }
コード例 #12
0
 public bool SaveOrganization(Organization org, out ResponseMessage responseMessage)
 {
     if (Request.Files.Count > 0)
     {
         for (int i = 0; i < Request.Files.Count; i++)
         {
             var file = Request.Files[i];
             if (file != null)
             {
                 byte[] data = null;
                 using (var br = new BinaryReader(file.InputStream))
                 {
                     data = br.ReadBytes(file.ContentLength);
                 }
                 org.StateImages.Add(new OrgStateImage(data));
             }
         }
     }
     bool complete = org.Save(out responseMessage);
     return complete;
 }
コード例 #13
0
ファイル: RestHoliday.cs プロジェクト: aleks19921015/Stuff
 public static bool Delete(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHoliday/Close?id={1}",OdataServiceUri,id));
     return PostJson(uri, string.Empty, out responseMessage);
 }
コード例 #14
0
ファイル: RestHoliday.cs プロジェクト: aleks19921015/Stuff
 public static bool Confirm(int[] idArray, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHoliday/Confirm",OdataServiceUri));
     var json = JsonConvert.SerializeObject(idArray);
     return PostJson(uri, json, out responseMessage);
 }
コード例 #15
0
ファイル: RestHoliday.cs プロジェクト: aleks19921015/Stuff
 public bool Save(out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHoliday/Save",OdataServiceUri));
     var jsonRestHoliday = JsonConvert.SerializeObject(this);
     return PostJson(uri, jsonRestHoliday, out responseMessage);
 }
コード例 #16
0
 public static bool SetQuestionSent(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/Question/SetQuestionSent?id={1}", OdataServiceUri, id));
     string json = String.Empty;//String.Format("{{\"id\":{0}}}",id);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #17
0
ファイル: StatementPrint.cs プロジェクト: aleks19921015/Stuff
 public static bool SetConfirmed(int id, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(String.Format("{0}/Statement/SetConfirmed?id={1}", OdataServiceUri,id));
     string json = String.Empty;
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #18
0
ファイル: Employee.cs プロジェクト: WakeDown/UnitApis
 public static bool SetNewbieDeliverySend(out ResponseMessage responseMessage,params Employee[] emps)
 {
     Uri uri = new Uri(String.Format("{0}/Employee/SetDeliverySend", OdataServiceUri));
     string json = JsonConvert.SerializeObject(emps);
     bool result = PostJson(uri, json, out responseMessage);
     return result;
 }
コード例 #19
0
 public static bool CanEdit(string employeeSid, int year, bool canEdit, out ResponseMessage responseMessage)
 {
     Uri uri = new Uri(string.Format("{0}/RestHoliday/CanEdit?employeeSid={employeeSid}&year={1}&canEdit={2}", OdataServiceUri, year, canEdit));
     return PostJson(uri, String.Empty, out responseMessage);
 }
コード例 #20
0
        public bool SaveEmployee(Employee emp, out ResponseMessage responseMessage)
        {
            if (Request.Files.Count > 0 && Request.Files[0] != null && Request.Files[0].ContentLength > 0)
            {
                var file = Request.Files[0];

                string ext = Path.GetExtension(file.FileName).ToLower();

                if (ext != ".png" && ext != ".jpeg" && ext != ".jpg" && ext != ".gif") throw new Exception("Формат фотографии должен быть .png .jpeg .gif");

                byte[] picture = null;
                using (var br = new BinaryReader(file.InputStream))
                {
                    picture = br.ReadBytes(file.ContentLength);
                }
                emp.Photo = picture;
            }
            emp.Creator = new Employee(){AdSid = GetCurUser().Sid};
            //var chkCreateAdUser = Request.Form["chkCreateAdUser"];
            //bool createAdUser = chkCreateAdUser != "false";
            bool complete = emp.Save(out responseMessage);
            return complete;
        }
コード例 #21
0
 public ActionResult StatementPrintList(int id)
 {
     if (!CurUser.UserIsPersonalManager())
         return new HttpStatusCodeResult(403);
     var responseMessage = new ResponseMessage();
     StatementPrint.SetConfirmed(id, out responseMessage);
     ViewData["message"] = responseMessage;
     var spl = StatementPrint.GetList();
     return View(spl);
 }